aboutsummaryrefslogtreecommitdiff
path: root/libiberty/pex-common.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2010-08-20 23:58:16 +0000
committerDJ Delorie <dj@redhat.com>2010-08-20 23:58:16 +0000
commit23701f2e4d5671af56e0f3383bfa4dd2e6ba0214 (patch)
treea362c1e97db20cb70e7179e29595d8d49352f735 /libiberty/pex-common.c
parent3409e291c1c178630a26ca916cd178c0c07e2fd9 (diff)
downloadgdb-23701f2e4d5671af56e0f3383bfa4dd2e6ba0214.zip
gdb-23701f2e4d5671af56e0f3383bfa4dd2e6ba0214.tar.gz
gdb-23701f2e4d5671af56e0f3383bfa4dd2e6ba0214.tar.bz2
merge from gcc
Diffstat (limited to 'libiberty/pex-common.c')
-rw-r--r--libiberty/pex-common.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libiberty/pex-common.c b/libiberty/pex-common.c
index 9a9fe24..b32c54c 100644
--- a/libiberty/pex-common.c
+++ b/libiberty/pex-common.c
@@ -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)
{