From 59a2f13e7e72ed259a8590c5417baeca1d1b0ae9 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 25 Apr 2012 21:34:05 +0400 Subject: [PATCH] Helper for si_code event extraction. Signed-off-by: Pavel Emelyanov --- include/ptrace.h | 2 ++ parasite-syscall.c | 4 ++-- ptrace.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/ptrace.h b/include/ptrace.h index b5d2c6120..43a90e9d8 100644 --- a/include/ptrace.h +++ b/include/ptrace.h @@ -32,6 +32,8 @@ #define PTRACE_O_TRACEVFORKDONE 0x00000020 #define PTRACE_O_TRACEEXIT 0x00000040 +#define SI_EVENT(_si_code) (((_si_code) & 0xFFFF) >> 8) + extern int seize_task(pid_t pid, pid_t ppid, pid_t *pgid, pid_t *sid); extern int unseize_task(pid_t pid, int state); extern int ptrace_peek_area(pid_t pid, void *dst, void *addr, long bytes); diff --git a/parasite-syscall.c b/parasite-syscall.c index 1b8f3f67c..213fa93af 100644 --- a/parasite-syscall.c +++ b/parasite-syscall.c @@ -171,7 +171,7 @@ retry_signal: goto err; } - if (((siginfo.si_code & 0xffff) >> 8) != PTRACE_EVENT_STOP) + if (SI_EVENT(siginfo.si_code) != PTRACE_EVENT_STOP) goto retry_signal; /* @@ -218,7 +218,7 @@ retry_signal: goto err; } - if (((siginfo.si_code & 0xffff) >> 8) != PTRACE_EVENT_STOP) { + if (SI_EVENT(siginfo.si_code) != PTRACE_EVENT_STOP) { pr_err("si_code doesn't match (pid: %d si_code: %d)\n", pid, siginfo.si_code); goto err; diff --git a/ptrace.c b/ptrace.c index 887b397fc..971f004cc 100644 --- a/ptrace.c +++ b/ptrace.c @@ -113,7 +113,7 @@ try_again: goto err; } - if (((si.si_code & 0xffff)>> 8) != PTRACE_EVENT_STOP) { + if (SI_EVENT(si.si_code) != PTRACE_EVENT_STOP) { /* * Kernel notifies us about the task being seized received some * event other than the STOP, i.e. -- a signal. Let the task