aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2020-06-21 00:22:56 -0700
committerMattias Andrée <maandree@kth.se>2020-06-21 09:44:02 +0200
commit87e992ccfb6d22b3e6fc1247180cf2bf1e464183 (patch)
tree474a6cfb7dcaa0e4eaa2ff2f1bcc92159728733d
parentInclude linux/fs.h for lseek and renameat2 flags (diff)
downloadsctrace-87e992ccfb6d22b3e6fc1247180cf2bf1e464183.tar.gz
sctrace-87e992ccfb6d22b3e6fc1247180cf2bf1e464183.tar.bz2
sctrace-87e992ccfb6d22b3e6fc1247180cf2bf1e464183.tar.xz
Use standard W* macros to check stop signal
-rw-r--r--process.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/process.c b/process.c
index 117fd6a..7e7a54f 100644
--- a/process.c
+++ b/process.c
@@ -29,7 +29,7 @@ struct process *
add_process(pid_t pid, unsigned long int trace_options)
{
struct process *proc;
- int status;
+ int status, sig;
proc = calloc(1, sizeof(*proc));
if (!proc)
@@ -46,22 +46,18 @@ add_process(pid_t pid, unsigned long int trace_options)
eprintf_and_kill(pid, "waitpid %ju <buffer> WSTOPPED:", (uintmax_t)pid);
}
- switch (status) {
- case __W_STOPCODE(SIGSTOP):
+ sig = WIFSTOPPED(status) ? WSTOPSIG(status) : 0;
+ if (sig == 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):
+ } else if (sig == SIGTRAP && status & 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:
+ } else {
eprintf_and_kill(pid, "unexpected return of waitpid %ju <buffer> WSTOPPED: %#x\n", (uintmax_t)pid, status);
}