Mercurial > hg > CbC > CbC_gcc
comparison 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 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
1 /* Common code for executing a program in a sub-process. | 1 /* Common code for executing a program in a sub-process. |
2 Copyright (C) 2005 Free Software Foundation, Inc. | 2 Copyright (C) 2005, 2010 Free Software Foundation, Inc. |
3 Written by Ian Lance Taylor <ian@airs.com>. | 3 Written by Ian Lance Taylor <ian@airs.com>. |
4 | 4 |
5 This file is part of the libiberty library. | 5 This file is part of the libiberty library. |
6 Libiberty is free software; you can redistribute it and/or | 6 Libiberty is free software; you can redistribute it and/or |
7 modify it under the terms of the GNU Library General Public | 7 modify it under the terms of the GNU Library General Public |
503 | 503 |
504 o = obj->stderr_pipe; | 504 o = obj->stderr_pipe; |
505 if (o < 0 || o == STDIN_FILE_NO) | 505 if (o < 0 || o == STDIN_FILE_NO) |
506 return NULL; | 506 return NULL; |
507 obj->read_err = obj->funcs->fdopenr (obj, o, binary); | 507 obj->read_err = obj->funcs->fdopenr (obj, o, binary); |
508 obj->stderr_pipe = -1; | |
508 return obj->read_err; | 509 return obj->read_err; |
509 } | 510 } |
510 | 511 |
511 /* Get the exit status and, if requested, the resource time for all | 512 /* Get the exit status and, if requested, the resource time for all |
512 the child processes. Return 0 on failure, 1 on success. */ | 513 the child processes. Return 0 on failure, 1 on success. */ |
595 /* Free a pex_obj structure. */ | 596 /* Free a pex_obj structure. */ |
596 | 597 |
597 void | 598 void |
598 pex_free (struct pex_obj *obj) | 599 pex_free (struct pex_obj *obj) |
599 { | 600 { |
601 /* Close pipe file descriptors corresponding to child's stdout and | |
602 stderr so that the child does not hang trying to output something | |
603 while we're waiting for it. */ | |
600 if (obj->next_input >= 0 && obj->next_input != STDIN_FILE_NO) | 604 if (obj->next_input >= 0 && obj->next_input != STDIN_FILE_NO) |
601 obj->funcs->close (obj, obj->next_input); | 605 obj->funcs->close (obj, obj->next_input); |
606 if (obj->stderr_pipe >= 0 && obj->stderr_pipe != STDIN_FILE_NO) | |
607 obj->funcs->close (obj, obj->stderr_pipe); | |
608 if (obj->read_output != NULL) | |
609 fclose (obj->read_output); | |
610 if (obj->read_err != NULL) | |
611 fclose (obj->read_err); | |
602 | 612 |
603 /* If the caller forgot to wait for the children, we do it here, to | 613 /* If the caller forgot to wait for the children, we do it here, to |
604 avoid zombies. */ | 614 avoid zombies. */ |
605 if (obj->status == NULL) | 615 if (obj->status == NULL) |
606 { | 616 { |
617 free (obj->children); | 627 free (obj->children); |
618 if (obj->status != NULL) | 628 if (obj->status != NULL) |
619 free (obj->status); | 629 free (obj->status); |
620 if (obj->time != NULL) | 630 if (obj->time != NULL) |
621 free (obj->time); | 631 free (obj->time); |
622 if (obj->read_output != NULL) | |
623 fclose (obj->read_output); | |
624 if (obj->read_err != NULL) | |
625 fclose (obj->read_err); | |
626 | 632 |
627 if (obj->remove_count > 0) | 633 if (obj->remove_count > 0) |
628 { | 634 { |
629 int i; | 635 int i; |
630 | 636 |