fail soft if sandboxee exits before init is ptraced

PiperOrigin-RevId: 270254470
Change-Id: Ifa13f4fe0e7ae91b79fc689e1d7dcb2a49b09cde
This commit is contained in:
Wiktor Garbacz 2019-09-20 06:13:08 -07:00 committed by Copybara-Service
parent 0aec7a511b
commit d43d09c746

View File

@ -205,7 +205,13 @@ void Monitor::Run() {
&init_pid); &init_pid);
if (init_pid > 0) { if (init_pid > 0) {
PCHECK(ptrace(PTRACE_SEIZE, init_pid, 0, PTRACE_O_EXITKILL) == 0); if (ptrace(PTRACE_SEIZE, init_pid, 0, PTRACE_O_EXITKILL) != 0) {
if (errno == ESRCH) {
SetExitStatusCode(Result::SETUP_ERROR, Result::FAILED_PTRACE);
return;
}
PLOG(FATAL) << "attaching to init process failed";
}
} }
if (pid_ <= 0 || (should_have_init && init_pid <= 0)) { if (pid_ <= 0 || (should_have_init && init_pid <= 0)) {