Kaynağa Gözat

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

David McCullough 21 yıl önce
ebeveyn
işleme
bf10e6efd4
1 değiştirilmiş dosya ile 2 ekleme ve 1 silme
  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;
 }