1
0
mirror of https://github.com/golang/go synced 2024-11-25 01:27:56 -07:00

os: correctly handle errno==0 in (*Process).blockUntilWaitable

CL 627478 inadvertently returns a non-nil error
containing a syscall.Errno(0).

Change-Id: I1d6a9d0575d3ed651ddc02f30505437d0d266bb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/629515
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Damien Neil 2024-11-18 14:39:20 -08:00 committed by Gopher Robot
parent a65f1a467f
commit b8fe88393b
2 changed files with 8 additions and 2 deletions

View File

@ -17,7 +17,10 @@ import (
func (p *Process) blockUntilWaitable() (bool, error) { func (p *Process) blockUntilWaitable() (bool, error) {
err := ignoringEINTR(func() error { err := ignoringEINTR(func() error {
_, errno := wait6(_P_PID, p.Pid, syscall.WEXITED|syscall.WNOWAIT) _, errno := wait6(_P_PID, p.Pid, syscall.WEXITED|syscall.WNOWAIT)
return errno if errno != 0 {
return errno
}
return nil
}) })
runtime.KeepAlive(p) runtime.KeepAlive(p)
if err == syscall.ENOSYS { if err == syscall.ENOSYS {

View File

@ -29,7 +29,10 @@ func (p *Process) blockUntilWaitable() (bool, error) {
psig := &siginfo[0] psig := &siginfo[0]
err := ignoringEINTR(func() error { err := ignoringEINTR(func() error {
_, _, errno := syscall.Syscall6(syscall.SYS_WAITID, _P_PID, uintptr(p.Pid), uintptr(unsafe.Pointer(psig)), syscall.WEXITED|syscall.WNOWAIT, 0, 0) _, _, errno := syscall.Syscall6(syscall.SYS_WAITID, _P_PID, uintptr(p.Pid), uintptr(unsafe.Pointer(psig)), syscall.WEXITED|syscall.WNOWAIT, 0, 0)
return errno if errno != 0 {
return errno
}
return nil
}) })
runtime.KeepAlive(p) runtime.KeepAlive(p)
if err != nil { if err != nil {