summaryrefslogtreecommitdiff
path: root/dmake
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@novell.com>2011-07-22 10:58:00 +0100
committerMichael Meeks <michael.meeks@novell.com>2011-07-22 10:59:08 +0100
commit8b857bd5b0548d0d15e3146b116d639c4dd08dbd (patch)
treef48697e56f653be4c8866f12d5e82f9c7a948a3a /dmake
parent30f80d74dfe30155085d03b4959854ea5c4b0898 (diff)
don't let our fprintf on a broken pipe pollute errno's ECHILD with EPIPE
Diffstat (limited to 'dmake')
-rw-r--r--dmake/unix/runargv.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/dmake/unix/runargv.c b/dmake/unix/runargv.c
index 42b9c25e66a9..2ea22cb63da0 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 {