1999-03-29 Paul Eggert <eggert@twinsun.com>

* libio/iopopen.c (_IO_new_proc_open): Don't modify proc_file_chain 
while in child process.
This commit is contained in:
Andreas Schwab 1999-03-29 16:01:58 +00:00
parent ae6b873031
commit 3c4936302a

View File

@ -139,6 +139,8 @@ _IO_new_proc_open (fp, command, mode)
if (child_pid == 0) if (child_pid == 0)
{ {
int child_std_end = mode[0] == 'r' ? 1 : 0; int child_std_end = mode[0] == 'r' ? 1 : 0;
struct _IO_proc_file *p;
_IO_close (parent_end); _IO_close (parent_end);
if (child_end != child_std_end) if (child_end != child_std_end)
{ {
@ -148,11 +150,8 @@ _IO_new_proc_open (fp, command, mode)
/* POSIX.2: "popen() shall ensure that any streams from previous /* POSIX.2: "popen() shall ensure that any streams from previous
popen() calls that remain open in the parent process are closed popen() calls that remain open in the parent process are closed
in the new child process." */ in the new child process." */
while (proc_file_chain) for (p = proc_file_chain; p; p = p->next)
{ _IO_close (_IO_fileno ((_IO_FILE *) p));
_IO_close (_IO_fileno ((_IO_FILE *) proc_file_chain));
proc_file_chain = proc_file_chain->next;
}
_IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0); _IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0);
_IO__exit (127); _IO__exit (127);