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>
This commit is contained in:
Mike Smith 1998-10-15 01:47:40 +00:00
parent d6e03c9b6d
commit 26c51fb453
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=40367

View File

@ -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 */