criu: check: don't leak the child if PTRACE_ATTACH fails

PS: never ever use PTRACE_KILL.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Oleg Nesterov 2014-12-06 23:25:00 +03:00 committed by Pavel Emelyanov
parent 5d9c83cf88
commit 40ae0fa35a

View file

@ -548,8 +548,11 @@ static int check_ptrace_peeksiginfo()
exit(1);
}
if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) == -1)
return -1;
if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) == -1) {
pr_perror("Unable to ptrace the child");
ret = -1;
goto out;
}
waitpid(pid, NULL, 0);
@ -567,8 +570,8 @@ static int check_ptrace_peeksiginfo()
ret = -1;
}
ptrace(PTRACE_KILL, pid, NULL, NULL);
out:
kill(pid, SIGKILL);
return ret;
}