[CRIU] [PATCH 2/2] ptrace: wait when queued SIGSTOP signals will be handled (v2)

Andrey Vagin avagin at openvz.org
Thu Nov 19 06:38:20 PST 2015


From: Andrew Vagin <avagin at virtuozzo.com>

SIGSTOP can't be blocked, so we need to wait when it will be handled.

v2: don't duplicate the same code twice

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 ptrace.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/ptrace.c b/ptrace.c
index b28824b..5a5fe5b 100644
--- a/ptrace.c
+++ b/ptrace.c
@@ -193,10 +193,16 @@ try_again:
 	if (cr.seccomp_mode != SECCOMP_MODE_DISABLED && suspend_seccomp(pid) < 0)
 		goto err;
 
-	if (si.si_signo == SIGTRAP)
-		return TASK_ALIVE;
-	else if (si.si_signo == SIGSTOP) {
+	if (cr.sigpnd & (1 << (SIGSTOP - 1)) || si.si_signo == SIGSTOP) {
 		/*
+		 * 1) SIGSTOP is queued, but isn't handled yet:
+		 * SGISTOP can't be blocked, so we need to wait when the kernel
+		 * handles this signal.
+		 *
+		 * Otherwise the process will be stopped immediatly after
+		 * starting it.
+		 *
+		 * 2) A seized task was stopped:
 		 * PTRACE_SEIZE doesn't affect signal or group stop state.
 		 * Currently ptrace reported that task is in stopped state.
 		 * We need to start task again, and it will be trapped
@@ -225,7 +231,11 @@ try_again:
 		}
 
 		return TASK_STOPPED;
-	} else {
+	}
+
+	if (si.si_signo == SIGTRAP)
+		return TASK_ALIVE;
+	else {
 		pr_err("SEIZE %d: unsupported stop signal %d\n", pid, si.si_signo);
 		goto err;
 	}
-- 
2.4.3



More information about the CRIU mailing list