Panic a bit less when we see an unknown pid

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>
This commit is contained in:
Denys Vlasenko 2013-06-21 16:19:46 +02:00
parent e2567d54dd
commit 71d3d29a9d

View File

@ -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;
}
}