ptrace: detect if a stub process exited unexpectedly

PiperOrigin-RevId: 263880577
This commit is contained in:
Andrei Vagin 2019-08-16 17:32:20 -07:00 committed by gVisor bot
parent f7114e0a27
commit 2a1303357c
1 changed files with 3 additions and 0 deletions

View File

@ -354,6 +354,9 @@ func (t *thread) wait(outcome waitOutcome) syscall.Signal {
continue // Spurious stop. continue // Spurious stop.
} }
if stopSig == syscall.SIGTRAP { if stopSig == syscall.SIGTRAP {
if status.TrapCause() == syscall.PTRACE_EVENT_EXIT {
t.dumpAndPanic("wait failed: the process exited")
}
// Re-encode the trap cause the way it's expected. // Re-encode the trap cause the way it's expected.
return stopSig | syscall.Signal(status.TrapCause()<<8) return stopSig | syscall.Signal(status.TrapCause()<<8)
} }