summaryrefslogtreecommitdiff
path: root/lib/libc/gen/popen.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-07-27 14:34:47 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-07-27 14:34:47 +0000
commit6a62f0086f2b755378f66cfe3b1df0817b998b0d (patch)
treecefbb5d8effce1354c7e66c1ab132697f61f96b7 /lib/libc/gen/popen.c
parent7f82b0562044f0296e49881eff72852ecba14783 (diff)
close all pipes in child; netbsd pr#2575
Diffstat (limited to 'lib/libc/gen/popen.c')
-rw-r--r--lib/libc/gen/popen.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c
index ccc8bad7c0a..2be0e35bbe2 100644
--- a/lib/libc/gen/popen.c
+++ b/lib/libc/gen/popen.c
@@ -104,6 +104,12 @@ popen(program, type)
}
(void)close(pdes[1]);
}
+ /*
+ * because vfork() instead of fork(), must leak FILE *,
+ * but luckily we are terminally headed for an execl()
+ */
+ for (cur = pidlist; cur; cur = cur->next)
+ close(fileno(cur->fp));
execl(_PATH_BSHELL, "sh", "-c", program, NULL);
_exit(127);
/* NOTREACHED */