summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid McCullough <davidm@snapgear.com>2002-12-01 23:32:17 +0000
committerDavid McCullough <davidm@snapgear.com>2002-12-01 23:32:17 +0000
commitbf10e6efd441bcd261c325323dda0957d529abf5 (patch)
tree704c29a4b9292871145c1ec2deb1c4839da44b1c
parent2e08b7b87e47d9a430c1de47f684ec7c1d410c4f (diff)
If the wait failed in pclose it would return a random status code
instead of -1 as expected.
-rw-r--r--libc/stdio/popen.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libc/stdio/popen.c b/libc/stdio/popen.c
index ddf881899..2fd1fa832 100644
--- a/libc/stdio/popen.c
+++ b/libc/stdio/popen.c
@@ -64,7 +64,8 @@ int pclose(FILE *fd)
if (fclose(fd) != 0) {
return EOF;
}
- wait(&waitstat);
+ if (wait(&waitstat) == -1)
+ return -1;
return waitstat;
}