瀏覽代碼

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

David McCullough 21 年之前
父節點
當前提交
bf10e6efd4
共有 1 個文件被更改,包括 2 次插入1 次删除
  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;
 }