summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/stdio/popen.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libc/stdio/popen.c b/libc/stdio/popen.c
index cddc9d6c4..a77a82e66 100644
--- a/libc/stdio/popen.c
+++ b/libc/stdio/popen.c
@@ -34,8 +34,8 @@ FILE *popen (const char *command, const char *mode)
if ((fp = fdopen(pnr, mode)) != NULL) {
if ((pid = vfork()) == 0) { /* vfork -- child */
close(pnr);
- close(reading);
if (pr != reading) {
+ close(reading);
dup2(pr, reading);
close(pr);
}