diff options
author | Mattias Andrée <maandree@kth.se> | 2020-05-31 23:59:13 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2020-05-31 23:59:13 +0200 |
commit | 21be28b24b0ee5ea97f3752c00f3f740ffb5f6b6 (patch) | |
tree | ee86e6006b27e3ce4577e6d836e29476d17e596a | |
parent | Tracing fork children does not work (diff) | |
download | sctrace-21be28b24b0ee5ea97f3752c00f3f740ffb5f6b6.tar.gz sctrace-21be28b24b0ee5ea97f3752c00f3f740ffb5f6b6.tar.bz2 sctrace-21be28b24b0ee5ea97f3752c00f3f740ffb5f6b6.tar.xz |
Things work as expected again
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | process.c | 27 | ||||
-rw-r--r-- | sctrace.c | 2 |
2 files changed, 20 insertions, 9 deletions
@@ -45,14 +45,25 @@ add_process(pid_t pid, unsigned long int trace_options) continue; eprintf_and_kill(pid, "waitpid %ju <buffer> WSTOPPED:", (uintmax_t)pid); } - if (!WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP) - eprintf_and_kill(pid, "unexpected return of waitpid %ju <buffer> WSTOPPED:", (uintmax_t)pid); - if (ptrace(PTRACE_SEIZE, pid, 0, trace_options)) - eprintf_and_kill(pid, "ptrace PTRACE_SEIZE %ju 0 ...:", (uintmax_t)pid); - if (ptrace(PTRACE_INTERRUPT, pid, 0, 0)) - eprintf_and_kill(pid, "ptrace PTRACE_INTERRUPT %ju 0 0:", (uintmax_t)pid); - if (kill(pid, SIGCONT) < 0) - eprintf_and_kill(pid, "kill &ju SIGCONT:", (uintmax_t)pid); + + switch (status) { + case __W_STOPCODE(SIGSTOP): + if (ptrace(PTRACE_SEIZE, pid, 0, trace_options)) + eprintf_and_kill(pid, "ptrace PTRACE_SEIZE %ju 0 ...:", (uintmax_t)pid); + if (ptrace(PTRACE_INTERRUPT, pid, NULL, 0)) + eprintf_and_kill(pid, "ptrace PTRACE_INTERRUPT %ju NULL 0:", (uintmax_t)pid); + if (kill(pid, SIGCONT) < 0) + eprintf_and_kill(pid, "kill &ju SIGCONT:", (uintmax_t)pid); + break; + + case __W_STOPCODE(SIGTRAP) | (PTRACE_EVENT_STOP << 16): + if (ptrace(PTRACE_SYSCALL, pid, NULL, 0)) + eprintf_and_kill(pid, "ptrace PTRACE_SYSCALL %ju NULL 0:", (uintmax_t)pid); + break; + + default: + eprintf_and_kill(pid, "unexpected return of waitpid %ju <buffer> WSTOPPED: %#x\n", (uintmax_t)pid, status); + } return proc; } @@ -157,7 +157,7 @@ handle_event(struct process *proc, int status) abort(); case 0: - /* TODO ensure proper handling of signals (multithreaded?, siginfo?, in new processes?) */ + /* TODO ensure proper handling of signals (siginfo?) */ if (ptrace(PTRACE_GETSIGINFO, proc->pid, 0, &(siginfo_t){0})) goto stop_signal; tprintf(proc, "\nProcess received signal %i (%s: %s)\n", sig, get_signum_name(sig), strsignal(sig)); |