diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2013-06-26 14:29:19 +0200 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2013-06-26 14:58:03 +0200 |
commit | c8511f07aba78178f8528e22a8daa438347eb4fa (patch) | |
tree | b4698f568049e6d7765b639164e9082f91a0975f | |
parent | e8681c926c02dad48aca66f3aba1e33122002c36 (diff) | |
download | strace-c8511f07aba78178f8528e22a8daa438347eb4fa.tar.gz strace-c8511f07aba78178f8528e22a8daa438347eb4fa.tar.bz2 strace-c8511f07aba78178f8528e22a8daa438347eb4fa.tar.xz |
In -f mode, do not assume that new pid is stopped - handle exits too
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r-- | strace.c | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -1993,7 +1993,7 @@ trace(void) } if (pid == popen_pid) { - if (WIFEXITED(status) || WIFSIGNALED(status)) + if (!WIFSTOPPED(status)) popen_pid = 0; continue; } @@ -2017,6 +2017,7 @@ trace(void) if (WIFSTOPPED(status)) sprintf(buf, "WIFSTOPPED,sig=%s", signame(WSTOPSIG(status))); #ifdef WIFCONTINUED + /* Should never be seen */ if (WIFCONTINUED(status)) strcpy(buf, "WIFCONTINUED"); #endif @@ -2045,7 +2046,16 @@ trace(void) tcp = pid2tcb(pid); if (!tcp) { + if (!WIFSTOPPED(status)) { + /* This can happen if we inherited + * an unknown child. Example: + * (sleep 1 & exec strace sleep 2) + */ + error_msg("Exit of unknown pid %u seen", pid); + continue; + } if (followfork) { + /* We assume it's a fork/vfork/clone child */ tcp = alloctcb(pid); tcp->flags |= TCB_ATTACHED | TCB_STARTUP | post_attach_sigstop; newoutf(tcp); @@ -2054,16 +2064,10 @@ trace(void) pid); } else { /* This can happen if a clone call used - * CLONE_PTRACE itself, or if we inherited - * an unknown child. Example: - * (sleep 1 & exec strace sleep 2) + * CLONE_PTRACE itself. */ - if (WIFSTOPPED(status)) { - ptrace(PTRACE_CONT, pid, (char *) 0, 0); - error_msg("Stop of unknown pid %u seen, PTRACE_CONTed it", pid); - } else { - error_msg("Exit of unknown pid %u seen", pid); - } + ptrace(PTRACE_CONT, pid, (char *) 0, 0); + error_msg("Stop of unknown pid %u seen, PTRACE_CONTed it", pid); continue; } } |