[CRIU] [crtools-bot for Pavel Emelyanov ] dump: Let task handle signals on seize

Cyrill Gorcunov gorcunov at openvz.org
Thu Mar 1 11:36:36 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit cb0eb0b31ef1b0d5bce30b729d2db01b3633d522
Author: Pavel Emelyanov <xemul at parallels.com>
Date:   Thu Mar 1 20:25:39 2012 +0400

    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 <xemul at parallels.com>
    Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 ptrace.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/ptrace.c b/ptrace.c
index b26bdca..257048b 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)


More information about the CRIU mailing list