Browse Source

If the wait failed in pclose it would return a random status code
instead of -1 as expected.

David McCullough 21 years ago
parent
commit
bf10e6efd4
1 changed files with 2 additions and 1 deletions
  1. 2 1
      libc/stdio/popen.c

+ 2 - 1
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;
 }