diff options
author | 1996-07-27 14:34:46 +0000 | |
---|---|---|
committer | 1996-07-27 14:34:46 +0000 | |
commit | f42d672eb9751d74594e71ca2813e7910a505329 (patch) | |
tree | 66896d4a5c83931d997902daa1087a1647d3bcbb /lib/libc/gen/popen.c | |
parent | slight clarification. (diff) | |
download | wireguard-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.c | 6 |
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 */ |