summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/popen.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1996-07-27 14:34:46 +0000
committerderaadt <deraadt@openbsd.org>1996-07-27 14:34:46 +0000
commitf42d672eb9751d74594e71ca2813e7910a505329 (patch)
tree66896d4a5c83931d997902daa1087a1647d3bcbb /lib/libc/gen/popen.c
parentslight clarification. (diff)
downloadwireguard-openbsd-f42d672eb9751d74594e71ca2813e7910a505329.tar.xz
wireguard-openbsd-f42d672eb9751d74594e71ca2813e7910a505329.zip
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 */