Mercurial > hg > CbC > CbC_gcc
diff libiberty/pex-common.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | 77e2b8dfacca |
children | 04ced10e8804 |
line wrap: on
line diff
--- a/libiberty/pex-common.c Tue May 25 18:58:51 2010 +0900 +++ b/libiberty/pex-common.c Tue Mar 22 17:18:12 2011 +0900 @@ -1,5 +1,5 @@ /* Common code for executing a program in a sub-process. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2010 Free Software Foundation, Inc. Written by Ian Lance Taylor <ian@airs.com>. This file is part of the libiberty library. @@ -505,6 +505,7 @@ 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 @@ 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 @@ 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) {