rc

[fork] interactive rc shell
Log | Files | Refs | README | LICENSE

commit 709cabfe384362577d53b36817c70001fe9895af
parent 9abdba3fd5946e4af117a297957fdbf11504f801
Author: tgoodwin <tgoodwin>
Date:   Thu, 29 Oct 1998 14:15:41 +0000

  Portability: work around readline's broken treatment of a non-blocking
  input file descriptor.

Diffstat:
Mopen.c | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git 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; }