diff options
author | Michael Meeks <michael.meeks@novell.com> | 2011-07-22 10:58:00 +0100 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2011-07-22 14:43:24 +0200 |
commit | 6f12189a688278013443fa22207acfcb6b3f5c90 (patch) | |
tree | b0dde1a573daa313008cc8a0b238ad99c2ba5d11 | |
parent | 8d956763258c0f084327bfe8c2b8d5f4950283d0 (diff) |
don't let our fprintf on a broken pipe pollute errno's ECHILD with EPIPE
Signed-off-by: Fridrich Štrba <fridrich.strba@bluewin.ch>
-rw-r--r-- | dmake/unix/runargv.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/dmake/unix/runargv.c b/dmake/unix/runargv.c index 4d18eff15..8135e6758 100644 --- a/dmake/unix/runargv.c +++ b/dmake/unix/runargv.c @@ -269,9 +269,10 @@ dmwaitnext( wid, status ) /* If ECHILD is set from waitpid/wait then no child was left. */ if( *wid == -1 ) { - fprintf(stderr, "%s: Internal Error: wait() failed: %d - %s\n", - Pname, errno, strerror(errno) ); - if(errno != ECHILD) { + int realErr = errno; // fprintf can pollute errno + fprintf(stderr, "%s: Internal Error: wait() failed: %d - %s\n", + Pname, errno, strerror(errno) ); + if( realErr != ECHILD ) { /* Wait was interrupted or a child was terminated (SIGCHLD) */ return -2; } else { @@ -369,9 +370,10 @@ dmwaitpid( pqid, wid, status ) } /* If ECHILD is set from waitpid/wait then no child was left. */ if( *wid == -1 ) { + int realErr = errno; // fprintf can pollute errno fprintf(stderr, "%s: Internal Error: waitpid() failed: %d - %s\n", Pname, errno, strerror(errno) ); - if(errno != ECHILD) { + if(realErr != ECHILD) { /* Wait was interrupted or a child was terminated (SIGCHLD) */ return -2; } else { |