]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
1999-03-29 Paul Eggert <eggert@twinsun.com>
authorAndreas Schwab <schwab@suse.de>
Mon, 29 Mar 1999 16:01:58 +0000 (16:01 +0000)
committerAndreas Schwab <schwab@suse.de>
Mon, 29 Mar 1999 16:01:58 +0000 (16:01 +0000)
* libio/iopopen.c (_IO_new_proc_open): Don't modify proc_file_chain
while in child process.

libio/iopopen.c

index 31f9e02cd876dd916be470a1bbadd314b62e819f..3f3868d4ab7f2376b561d2e7c267bc27dce0d60b 100644 (file)
@@ -139,6 +139,8 @@ _IO_new_proc_open (fp, command, mode)
   if (child_pid == 0)
     {
       int child_std_end = mode[0] == 'r' ? 1 : 0;
+      struct _IO_proc_file *p;
+
       _IO_close (parent_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
          popen() calls that remain open in the parent process are closed
         in the new child process." */
-      while (proc_file_chain)
-       {
-         _IO_close (_IO_fileno ((_IO_FILE *) proc_file_chain));
-         proc_file_chain = proc_file_chain->next;
-       }
+      for (p = proc_file_chain; p; p = p->next)
+       _IO_close (_IO_fileno ((_IO_FILE *) p));
 
       _IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0);
       _IO__exit (127);