Commit d12317de authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

ptrace: call wait only if PTRACE_SEIZE was successful

and print errno for the wait syscall in an error case
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 99801e72
...@@ -50,7 +50,7 @@ int seize_task(pid_t pid, pid_t ppid) ...@@ -50,7 +50,7 @@ int seize_task(pid_t pid, pid_t ppid)
{ {
siginfo_t si; siginfo_t si;
int status; int status;
int ret, ret2, ptrace_errno; int ret, ret2, ptrace_errno, wait_errno = 0;
struct proc_status_creds cr; struct proc_status_creds cr;
ret = ptrace(PTRACE_SEIZE, pid, NULL, 0); ret = ptrace(PTRACE_SEIZE, pid, NULL, 0);
...@@ -81,7 +81,10 @@ int seize_task(pid_t pid, pid_t ppid) ...@@ -81,7 +81,10 @@ int seize_task(pid_t pid, pid_t ppid)
*/ */
try_again: try_again:
ret = wait4(pid, &status, __WALL, NULL); if (!ret) {
ret = wait4(pid, &status, __WALL, NULL);
wait_errno = errno;
}
ret2 = parse_pid_status(pid, &cr); ret2 = parse_pid_status(pid, &cr);
if (ret2) if (ret2)
...@@ -97,8 +100,8 @@ try_again: ...@@ -97,8 +100,8 @@ try_again:
if (pid == getpid()) if (pid == getpid())
pr_err("The criu itself is within dumped tree.\n"); pr_err("The criu itself is within dumped tree.\n");
else else
pr_err("Unseizable non-zombie %d found, state %c, err %d/%d\n", pr_err("Unseizable non-zombie %d found, state %c, err %d/%d/%d\n",
pid, cr.state, ret, ptrace_errno); pid, cr.state, ret, ptrace_errno, wait_errno);
return -1; return -1;
} }
...@@ -135,6 +138,7 @@ try_again: ...@@ -135,6 +138,7 @@ try_again:
goto err; goto err;
} }
ret = 0;
goto try_again; goto try_again;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment