From cb0eb0b31ef1b0d5bce30b729d2db01b3633d522 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 1 Mar 2012 20:25:39 +0400 Subject: [PATCH] dump: Let task handle signals on seize When seizing a task and waiting for it to stop, we can receive an event from kernel, that the task didn't stop, but caught a signal. Don't treat this as an error, let the victim handle it and proceed. The transition/fork test should work OK now. Signed-off-by: Pavel Emelyanov Signed-off-by: Cyrill Gorcunov --- ptrace.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ptrace.c b/ptrace.c index b26bdcab3..257048bf6 100644 --- a/ptrace.c +++ b/ptrace.c @@ -70,7 +70,7 @@ int seize_task(pid_t pid, pid_t ppid) pid, ppid, ps.ppid); goto err; } - +try_again: ret = ptrace(PTRACE_INTERRUPT, pid, NULL, NULL); if (ret < 0) { pr_perror("SEIZE %d: can't interrupt task", pid); @@ -100,9 +100,19 @@ int seize_task(pid_t pid, pid_t ppid) } if ((si.si_code >> 8) != PTRACE_EVENT_STOP) { - pr_err("SEIZE %d: wrong stop event received 0x%x\n", pid, - (unsigned int)si.si_code); - goto err; + /* + * Kernel notifies us about the task being seized received some + * event other than the STOP, i.e. -- a signal. Let the task + * handle one and repeat. + */ + + if (ptrace(PTRACE_CONT, pid, NULL, + (void *)(unsigned long)si.si_signo)) { + pr_perror("Can't continue signal handling. Aborting."); + goto err; + } + + goto try_again; } if (si.si_signo == SIGTRAP)