summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1998-10-15 01:47:40 +0000
committermsmith <msmith@FreeBSD.org>1998-10-15 01:47:40 +0000
commit59741c0a1610ce42adc937341ce3e0466ea3c3ce (patch)
tree3fdef53bb519b9dcff0ca687bc3184f155a47bb5 /lib/libc
parentec797a83354c9c374e6b3c59d8329e37c522ebf1 (diff)
downloadFreeBSD-src-59741c0a1610ce42adc937341ce3e0466ea3c3ce.zip
FreeBSD-src-59741c0a1610ce42adc937341ce3e0466ea3c3ce.tar.gz
Conform to POSIX and close any copies of popen() descriptors inherited by a
popen()ed child. PR: misc/7810 Submitted by: Wayne Scott <wscott@ichips.intel.com>
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/popen.c4
1 files changed, 4 insertions, 0 deletions
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 */
OpenPOWER on IntegriCloud