diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-24 20:41:37 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-24 20:41:37 +0000 |
commit | 247ebac8ed3803951ff2400571e714eaf033e541 (patch) | |
tree | cee198fcdcf79da66d9886a61667a7ea6623d5bd /gnu | |
parent | 088db4150d1a8f0c81cf49bd80dbc332225f8c87 (diff) |
watch our tempermental gnu child more carefully; bug spotted by graichen@axp5.physik.fu-berlin.de
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/bc/bcwrap/bcwrap.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/gnu/usr.bin/bc/bcwrap/bcwrap.c b/gnu/usr.bin/bc/bcwrap/bcwrap.c index 029ece5c1f6..3dc23619a67 100644 --- a/gnu/usr.bin/bc/bcwrap/bcwrap.c +++ b/gnu/usr.bin/bc/bcwrap/bcwrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcwrap.c,v 1.2 1996/07/22 10:10:39 deraadt Exp $ */ +/* $OpenBSD: bcwrap.c,v 1.3 1996/08/24 20:41:36 deraadt Exp $ */ /* * Copyright (c) 1996 Theo de Raadt <deraadt@theos.com> @@ -87,25 +87,23 @@ main(argc, argv) width = pd[1]; rfds = (1 << 0) || (1 << pd[1]); while (1) { + if (waitpid(pid, &stat, WNOHANG) > 0) + exit(WEXITSTATUS(stat)); switch (select(width, (fd_set *)&rfds, NULL, NULL, NULL)) { case -1: case 0: break; default: if (rfds & (1<<0) == 0) - break; + goto done; n = read(0, buf, sizeof buf); - if (n == 0) { - close(pd[1]); + if (n == 0) goto done; - } off = 0; while (off < n) { res = write(pd[1], buf + off, n - off); - if (res == -1 && errno != EAGAIN) { - close(pd[1]); + if (res == -1 && errno != EAGAIN) goto done; - } off += res; } } |