]> granicus.if.org Git - strace/commitdiff
Panic a bit less when we see an unknown pid
authorDenys Vlasenko <dvlasenk@redhat.com>
Fri, 21 Jun 2013 14:19:46 +0000 (16:19 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Fri, 21 Jun 2013 14:19:46 +0000 (16:19 +0200)
I stumbeld over this case when I used "exec stace ...".

* strace.c (trace): Do not exit if we see an unknown pid in wait4.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
strace.c

index 6e9ea91afb1b73fb7c343b6d6cd5e3da41da0d71..ab971b513e7dbd5c05ec911ba19a039d175c46ad 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -2055,10 +2055,17 @@ trace(void)
                                                pid);
                        } else {
                                /* This can happen if a clone call used
-                                  CLONE_PTRACE itself.  */
-                               if (WIFSTOPPED(status))
+                                * CLONE_PTRACE itself, or if we inherited
+                                * an unknown child. Example:
+                                * (sleep 1 & exec strace sleep 2)
+                                */
+                               if (WIFSTOPPED(status)) {
                                        ptrace(PTRACE_CONT, pid, (char *) 0, 0);
-                               error_msg_and_die("Unknown pid: %u", pid);
+                                       error_msg("Stop of unknown pid %u seen, PTRACE_CONTed it", pid);
+                               } else {
+                                       error_msg("Exit of unknown pid %u seen", pid);
+                               }
+                               continue;
                        }
                }