merge from gcc
authorDJ Delorie <dj@redhat.com>
Fri, 20 Aug 2010 23:58:16 +0000 (23:58 +0000)
committerDJ Delorie <dj@redhat.com>
Fri, 20 Aug 2010 23:58:16 +0000 (23:58 +0000)
libiberty/ChangeLog
libiberty/pex-common.c

index f09042d59d628a4ee709403382eb63ef15a09940..f404025a4baae005064f4a90e1fb628489b4cf7e 100644 (file)
@@ -1,3 +1,10 @@
+2010-08-20  Maciej W. Rozycki  <macro@codesourcery.com>
+
+       * pex-common.c (pex_read_err): Set stderr_pipe to -1 if a
+       corresponding stream has been opened.
+       (pex_free): Close pipe file descriptors corresponding to child's
+       stdout and stderr before waiting.
+
 2010-08-13  Nick Clifton  <nickc@redhat.com>
 
        * argv.c (expandargv): Limit the number of times that response
index 9a9fe2419570888171fc4460aa8665a10c6bfde3..b32c54cc683f07760f11c52ed4164a202fea0da2 100644 (file)
@@ -505,6 +505,7 @@ pex_read_err (struct pex_obj *obj, int binary)
   if (o < 0 || o == STDIN_FILE_NO)
     return NULL;
   obj->read_err = obj->funcs->fdopenr (obj, o, binary);
+  obj->stderr_pipe = -1;
   return obj->read_err;    
 }
 
@@ -597,8 +598,17 @@ pex_get_times (struct pex_obj *obj, int count, struct pex_time *vector)
 void
 pex_free (struct pex_obj *obj)
 {
+  /* Close pipe file descriptors corresponding to child's stdout and
+     stderr so that the child does not hang trying to output something
+     while we're waiting for it.  */
   if (obj->next_input >= 0 && obj->next_input != STDIN_FILE_NO)
     obj->funcs->close (obj, obj->next_input);
+  if (obj->stderr_pipe >= 0 && obj->stderr_pipe != STDIN_FILE_NO)
+    obj->funcs->close (obj, obj->stderr_pipe);
+  if (obj->read_output != NULL)
+    fclose (obj->read_output);
+  if (obj->read_err != NULL)
+    fclose (obj->read_err);
 
   /* If the caller forgot to wait for the children, we do it here, to
      avoid zombies.  */
@@ -619,10 +629,6 @@ pex_free (struct pex_obj *obj)
     free (obj->status);
   if (obj->time != NULL)
     free (obj->time);
-  if (obj->read_output != NULL)
-    fclose (obj->read_output);
-  if (obj->read_err != NULL)
-    fclose (obj->read_err);
 
   if (obj->remove_count > 0)
     {
This page took 0.029412 seconds and 4 git commands to generate.