diff options
author | macro <macro@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-20 22:39:58 +0000 |
---|---|---|
committer | macro <macro@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-20 22:39:58 +0000 |
commit | 7492a1088def8c9bbbf876d19814ee720650b779 (patch) | |
tree | a57e67974483fcf221523c327577dc6cb1a5e447 /libiberty | |
parent | 98ff07a965b12a481854f4a2945612edeb0c6144 (diff) | |
download | gcc-7492a1088def8c9bbbf876d19814ee720650b779.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163426 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 7 | ||||
-rw-r--r-- | libiberty/pex-common.c | 14 |
2 files changed, 17 insertions, 4 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index f09042d59d6..f404025a4ba 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -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 diff --git a/libiberty/pex-common.c b/libiberty/pex-common.c index 9a9fe241957..b32c54cc683 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) { |