[CRIU] [PATCH] proc: parse /proc/pid/status when a task is stopped

Andrey Vagin avagin at openvz.org
Sun Feb 22 23:34:39 PST 2015


If we parse /proc/pid/status when a task isn't stopped,
we can't be sure that a process state will not be changed.

08:58:48 Test: zdtm/live/user/static/zombie00, Namespace: 1
08:58:48 Dump log   : /var/lib/jenkins/jobs/CRIU-dump/workspace/test/dump/ns/user/static/zombie00/114/1/dump.log
08:58:48 --------------------------------- grep Error ---------------------------------
08:58:48 (00.001127) Error (ptrace.c:124): SEIZE 121: task not stopped after seize

Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 ptrace.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/ptrace.c b/ptrace.c
index f258a43..9696a6e 100644
--- a/ptrace.c
+++ b/ptrace.c
@@ -80,6 +80,18 @@ int seize_task(pid_t pid, pid_t ppid)
 	 * we might nead at that early point.
 	 */
 
+try_again:
+	ret = wait4(pid, &status, __WALL, NULL);
+	if (ret < 0) {
+		if (errno != ECHILD) { /* isn't zombie */
+			pr_perror("SEIZE %d: can't wait task", pid);
+			goto err;
+		}
+	} else	if (ret != pid) {
+		pr_err("SEIZE %d: wrong task attached (%d)\n", pid, ret);
+		goto err;
+	}
+
 	ret2 = parse_pid_status(pid, &cr);
 	if (ret2)
 		goto err;
@@ -108,18 +120,6 @@ int seize_task(pid_t pid, pid_t ppid)
 		goto err;
 	}
 
-try_again:
-	ret = wait4(pid, &status, __WALL, NULL);
-	if (ret < 0) {
-		pr_perror("SEIZE %d: can't wait task", pid);
-		goto err;
-	}
-
-	if (ret != pid) {
-		pr_err("SEIZE %d: wrong task attached (%d)\n", pid, ret);
-		goto err;
-	}
-
 	if (!WIFSTOPPED(status)) {
 		pr_err("SEIZE %d: task not stopped after seize\n", pid);
 		goto err;
-- 
1.9.3



More information about the CRIU mailing list