From 59741c0a1610ce42adc937341ce3e0466ea3c3ce Mon Sep 17 00:00:00 2001 From: msmith Date: Thu, 15 Oct 1998 01:47:40 +0000 Subject: Conform to POSIX and close any copies of popen() descriptors inherited by a popen()ed child. PR: misc/7810 Submitted by: Wayne Scott --- lib/libc/gen/popen.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/libc') diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c index 8616671..bcbd164 100644 --- a/lib/libc/gen/popen.c +++ b/lib/libc/gen/popen.c @@ -65,6 +65,7 @@ popen(command, type) FILE *iop; int pdes[2], pid, twoway; char *argv[4]; + struct pid *p; /* * Lite2 introduced two-way popen() pipes using socketpair(). @@ -124,6 +125,9 @@ popen(command, type) } (void)close(pdes[1]); } + for (p = pidlist; p; p = p->next) { + (void)close(fileno(p->fp)); + } execve(_PATH_BSHELL, argv, environ); _exit(127); /* NOTREACHED */ -- cgit v1.1