rc

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

commit 5fd501ac0bf1a9d8515e7267016e87b35bc39ba6
parent 918e8f9b8935ad2034bc0d458c64d5c688b2bab5
Author: tgoodwin <tgoodwin>
Date:   Wed, 15 Jul 1998 12:39:30 +0000

tidy this up a bit

Diffstat:
Msystem-bsd.c | 38++++++++++++--------------------------
1 file changed, 12 insertions(+), 26 deletions(-)

diff --git a/system-bsd.c b/system-bsd.c @@ -19,16 +19,12 @@ extern void writeall(int fd, char *buf, size_t remain) { safe_buf = buf; safe_remain = remain; for (i = 0; safe_remain > 0; buf += i, safe_remain -= i) { - interrupt_happened = FALSE; - if (!sigsetjmp(slowbuf.j, 1)) { + if (sigsetjmp(slowbuf.j, 1) == 0) { slow = TRUE; - if (interrupt_happened) - break; - else if ((i = write(fd, safe_buf, safe_remain)) <= 0) + if ((i = write(fd, safe_buf, safe_remain)) <= 0) break; /* abort silently on errors in write() */ } else break; - slow = FALSE; } slow = FALSE; sigchk(); @@ -37,38 +33,28 @@ extern void writeall(int fd, char *buf, size_t remain) { extern int rc_read(int fd, char *buf, size_t n) { ssize_t r; - interrupt_happened = FALSE; - if (!sigsetjmp(slowbuf.j, 1)) { + if (sigsetjmp(slowbuf.j, 1) == 0) { slow = TRUE; - if (!interrupt_happened) - r = read(fd, buf, n); - else - r = -2; - } else - r = -2; - slow = FALSE; - if (r == -2) { + r = read(fd, buf, n); + } else { errno = EINTR; r = -1; } + slow = FALSE; + return r; } static int r = -1; extern pid_t rc_wait(int *stat) { - interrupt_happened = FALSE; - if (!sigsetjmp(slowbuf.j, 1)) { + if (sigsetjmp(slowbuf.j, 1) == 0) { slow = TRUE; - if (!interrupt_happened) - r = wait(stat); - else - r = -2; - } else - r = -2; - slow = FALSE; - if (r == -2) { + r = wait(stat); + } else { errno = EINTR; r = -1; } + slow = FALSE; + return r; }