From: Roland McGrath Date: Tue, 17 Dec 2002 04:50:47 +0000 (+0000) Subject: 2002-12-16 Roland McGrath X-Git-Tag: v4.5.18~943 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5bc05558bb9f9acd1f895ea128f3326ef4b03338;p=strace 2002-12-16 Roland McGrath * strace.c (trace) [LINUX]: Only check errno if wait4 actually fails, so we don't repeat a wait and thus drop a status. Fixes RH#62591. --- diff --git a/strace.c b/strace.c index ec8d7527..67e832d3 100644 --- a/strace.c +++ b/strace.c @@ -1679,14 +1679,14 @@ trace() #ifdef LINUX #ifdef __WALL pid = wait4(-1, &status, wait4_options, cflag ? &ru : NULL); - if ((wait4_options & __WALL) && errno == EINVAL) { + if (pid < 0 && (wait4_options & __WALL) && errno == EINVAL) { /* this kernel does not support __WALL */ wait4_options &= ~__WALL; errno = 0; pid = wait4(-1, &status, wait4_options, cflag ? &ru : NULL); } - if (!(wait4_options & __WALL) && errno == ECHILD) { + if (pid < 0 && !(wait4_options & __WALL) && errno == ECHILD) { /* most likely a "cloned" process */ pid = wait4(-1, &status, __WCLONE, cflag ? &ru : NULL);