未验证 提交 1374962f 编写于 作者: A Alessandro Arzilli 提交者: GitHub

proc/native/linux: get exit status if proc exits after receiving signal (#2195)

If the process receives a signal (or sends a singal to itself) and then
dies before we can route the signal back to it we still need to
retrieve its exit status.

Fixes a rare failure of TestIssue1101 in proc_test.go
Co-authored-by: Na <a@kra>
上级 5632cf92
......@@ -276,6 +276,7 @@ type trapWaitOptions uint8
const (
trapWaitHalt trapWaitOptions = 1 << iota
trapWaitNohang
trapWaitDontCallExitGuard
)
func (dbp *nativeProcess) trapWaitInternal(pid int, options trapWaitOptions) (*nativeThread, error) {
......@@ -371,11 +372,10 @@ func (dbp *nativeProcess) trapWaitInternal(pid int, options trapWaitOptions) (*n
th.os.running = false
return th, nil
} else if err := th.resumeWithSig(int(status.StopSignal())); err != nil {
if err == sys.ESRCH {
dbp.postExit()
return nil, proc.ErrProcessExited{Pid: dbp.pid}
if options&trapWaitDontCallExitGuard != 0 {
return nil, err
}
return nil, err
return nil, dbp.exitGuard(err)
}
}
}
......@@ -445,7 +445,7 @@ func (dbp *nativeProcess) exitGuard(err error) error {
return err
}
if status(dbp.pid, dbp.os.comm) == statusZombie {
_, err := dbp.trapWaitInternal(-1, 0)
_, err := dbp.trapWaitInternal(-1, trapWaitDontCallExitGuard)
return err
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册