OSDN Git Service

libiberty/
authorjules <jules@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 17 May 2009 13:07:08 +0000 (13:07 +0000)
committerjules <jules@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 17 May 2009 13:07:08 +0000 (13:07 +0000)
* pex-win32.c (pex_win32_exec_child): Fix logic to avoid closing
standard handles (stdin, stdout, stderr) in parent.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147634 138bc75d-0d04-0410-961f-82ee72b054a4

libiberty/ChangeLog
libiberty/pex-win32.c

index 13c7fd5..75e76d6 100644 (file)
@@ -1,3 +1,8 @@
+2009-05-17  Julian Brown  <julian@codesourcery.com>
+
+       * pex-win32.c (pex_win32_exec_child): Fix logic to avoid closing
+       standard handles (stdin, stdout, stderr) in parent.
+
 2009-04-29  Julian Brown  <julian@codesourcery.com>
 
        * pex-win32.c (pex_win32_pipe): Add _O_NOINHERIT.    
 2009-04-29  Julian Brown  <julian@codesourcery.com>
 
        * pex-win32.c (pex_win32_pipe): Add _O_NOINHERIT.    
index 30ef435..91e0bc8 100644 (file)
@@ -753,17 +753,20 @@ pex_win32_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, int flags,
      original descriptors.  */
   orig_in = in;
   in = _dup (orig_in);
      original descriptors.  */
   orig_in = in;
   in = _dup (orig_in);
-  _close (orig_in);
+  if (orig_in != STDIN_FILENO)
+    _close (orig_in);
   
   orig_out = out;
   out = _dup (orig_out);
   
   orig_out = out;
   out = _dup (orig_out);
-  _close (orig_out);
+  if (orig_out != STDOUT_FILENO)
+    _close (orig_out);
   
   if (separate_stderr)
     {
       orig_err = errdes;
       errdes = _dup (orig_err);
   
   if (separate_stderr)
     {
       orig_err = errdes;
       errdes = _dup (orig_err);
-      _close (orig_err);
+      if (orig_err != STDERR_FILENO)
+       _close (orig_err);
     }
 
   stdin_handle = INVALID_HANDLE_VALUE;
     }
 
   stdin_handle = INVALID_HANDLE_VALUE;
@@ -844,11 +847,9 @@ pex_win32_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, int flags,
   /* Close the standard input, standard output and standard error handles
      in the parent.  */ 
 
   /* Close the standard input, standard output and standard error handles
      in the parent.  */ 
 
-  if (in != STDIN_FILENO)
-    _close (in);
-  if (out != STDOUT_FILENO)
-    _close (out);
-  if (errdes != STDERR_FILENO)
+  _close (in);
+  _close (out);
+  if (separate_stderr)
     _close (errdes);
 
   return pid;
     _close (errdes);
 
   return pid;