diff options
author | Ben Elliston <bje@au.ibm.com> | 2009-11-23 04:42:14 +0000 |
---|---|---|
committer | Ben Elliston <bje@au.ibm.com> | 2009-11-23 04:42:14 +0000 |
commit | c90188f694a64cb2b97cb9db99fe0c11aaba43d6 (patch) | |
tree | 932888c7956c4764f3b59ea1ea5a026d8c60bdea /libiberty | |
parent | 197fa1aa2ca7f943805196c37031b44f7b87d5a7 (diff) | |
download | gdb-c90188f694a64cb2b97cb9db99fe0c11aaba43d6.zip gdb-c90188f694a64cb2b97cb9db99fe0c11aaba43d6.tar.gz gdb-c90188f694a64cb2b97cb9db99fe0c11aaba43d6.tar.bz2 |
* 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.
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 7 | ||||
-rw-r--r-- | libiberty/pex-unix.c | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 4d16be4..79e0462 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,10 @@ +2009-11-23 Ben Elliston <bje@au.ibm.com> + Ian Lance Taylor <iant@google.com> + + * 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. + 2009-11-22 Steve Ward <planet36@gmail.com> * dyn-string.c (dyn_string_append_char): Fix typo in comment. diff --git a/libiberty/pex-unix.c b/libiberty/pex-unix.c index 3753812..4428f60 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. */ |