summaryrefslogtreecommitdiff
path: root/libiberty/pex-unix.c
diff options
context:
space:
mode:
authorbje <bje@138bc75d-0d04-0410-961f-82ee72b054a4>2009-11-23 04:42:32 +0000
committerbje <bje@138bc75d-0d04-0410-961f-82ee72b054a4>2009-11-23 04:42:32 +0000
commit01401934e56c424a09999977bdce54b2db33e929 (patch)
tree4de5ac8ddb846000f3be54cbd7905854fe6a78e7 /libiberty/pex-unix.c
parent4fb89a65e80877a98409db4d64588e3c55b42df3 (diff)
downloadgcc-01401934e56c424a09999977bdce54b2db33e929.tar.gz
* pex-unix.c (pex_child_error): Improve warning avoidance by
checking the results of write(3) and exiting with -2 if any write returns a negative value. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154431 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty/pex-unix.c')
-rw-r--r--libiberty/pex-unix.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libiberty/pex-unix.c b/libiberty/pex-unix.c
index 3753812b314..4428f60863f 100644
--- a/libiberty/pex-unix.c
+++ b/libiberty/pex-unix.c
@@ -368,7 +368,8 @@ static void
pex_child_error (struct pex_obj *obj, const char *executable,
const char *errmsg, int err)
{
-#define writeerr(s) if (write (STDERR_FILE_NO, s, strlen (s))) {}
+ int retval = 0;
+#define writeerr(s) retval |= (write (STDERR_FILE_NO, s, strlen (s)) < 0)
writeerr (obj->pname);
writeerr (": error trying to exec '");
writeerr (executable);
@@ -378,7 +379,8 @@ pex_child_error (struct pex_obj *obj, const char *executable,
writeerr (xstrerror (err));
writeerr ("\n");
#undef writeerr
- _exit (-1);
+ /* Exit with -2 if the error output failed, too. */
+ _exit (retval == 0 ? -1 : -2);
}
/* Execute a child. */