summaryrefslogtreecommitdiff
path: root/open.c
diff options
context:
space:
mode:
authortgoodwin <tgoodwin>1998-10-29 14:15:41 +0000
committerToby Goodwin <toby@paccrat.org>2015-05-16 21:23:12 +0100
commit709cabfe384362577d53b36817c70001fe9895af (patch)
tree2264548edc38970df8b2c7ec3826ce5c78e23185 /open.c
parent9abdba3fd5946e4af117a297957fdbf11504f801 (diff)
Portability: work around readline's broken treatment of a non-blocking
input file descriptor.
Diffstat (limited to 'open.c')
-rw-r--r--open.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/open.c b/open.c
index 2b2fb81..bac9f2c 100644
--- a/open.c
+++ b/open.c
@@ -24,10 +24,10 @@ extern int rc_open(const char *name, redirtype m) {
return open(name, mode_masks[m], 0666);
}
-/* make a file descriptor non blocking. must only be called after read()
-has returned EAGAIN. */
+/* make a file descriptor blocking. return value indicates whether
+the desciptor was previously set to non-blocking. */
-extern void makeblocking(int fd) {
+extern bool makeblocking(int fd) {
int flags;
if ((flags = fcntl(fd, F_GETFL)) == -1) {
@@ -35,10 +35,11 @@ extern void makeblocking(int fd) {
rc_error(NULL);
}
if (! (flags & O_NONBLOCK))
- panic("not O_NONBLOCK");
+ return FALSE;
flags &= ~O_NONBLOCK;
if (fcntl(fd, F_SETFL, (long) flags) == -1) {
uerror("fcntl");
rc_error(NULL);
}
+ return TRUE;
}