]> granicus.if.org Git - strace/commitdiff
2002-12-16 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Tue, 17 Dec 2002 04:50:47 +0000 (04:50 +0000)
committerRoland McGrath <roland@redhat.com>
Tue, 17 Dec 2002 04:50:47 +0000 (04:50 +0000)
* 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.

strace.c

index ec8d752717b16c7d493fad70115656d6ca4b9e43..67e832d39643cb1cfecd3a9dfbd707bae2cb7acc 100644 (file)
--- 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);