Skip to content

Commit b8fe883

Browse files
neildgopherbot
authored andcommitted
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Commit-Queue: Ian Lance Taylor <[email protected]>
1 parent a65f1a4 commit b8fe883

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/os/wait_wait6.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import (
1717
func (p *Process) blockUntilWaitable() (bool, error) {
1818
err := ignoringEINTR(func() error {
1919
_, errno := wait6(_P_PID, p.Pid, syscall.WEXITED|syscall.WNOWAIT)
20-
return errno
20+
if errno != 0 {
21+
return errno
22+
}
23+
return nil
2124
})
2225
runtime.KeepAlive(p)
2326
if err == syscall.ENOSYS {

src/os/wait_waitid.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ func (p *Process) blockUntilWaitable() (bool, error) {
2929
psig := &siginfo[0]
3030
err := ignoringEINTR(func() error {
3131
_, _, errno := syscall.Syscall6(syscall.SYS_WAITID, _P_PID, uintptr(p.Pid), uintptr(unsafe.Pointer(psig)), syscall.WEXITED|syscall.WNOWAIT, 0, 0)
32-
return errno
32+
if errno != 0 {
33+
return errno
34+
}
35+
return nil
3336
})
3437
runtime.KeepAlive(p)
3538
if err != nil {

0 commit comments

Comments
 (0)