Skip to content

Commit 9ec6990

Browse files
author
Bryan C. Mills
committed
os: use the correct constant for P_PID on NetBSD
Dragonfly and FreeBSD both used numerical values for these constants chosen to be the same as on Solaris. For some reason, NetBSD did not, and happens to interpret value 0 as P_ALL instead of P_PID (see https://github.com/NetBSD/src/blob/3323ceb7822f98b3d2693aa26fd55c4ded6d8ba4/sys/sys/idtype.h#L43-L44). Using the correct value for P_PID should cause wait6 to wait for the correct process, which may help to avoid the deadlocks reported in For #50138. Updates #13987. Change-Id: I0eacd1faee4a430d431fe48f9ccf837f49c42f39 Reviewed-on: https://go-review.googlesource.com/c/go/+/442478 Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Benny Siegert <[email protected]> Run-TryBot: Bryan Mills <[email protected]>
1 parent 4a4de14 commit 9ec6990

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/os/wait_wait6.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import (
1111
"syscall"
1212
)
1313

14-
const _P_PID = 0
14+
const (
15+
_P_PID = 0 // everywhere except for NetBSD?
16+
_P_PID_NETBSD = 1 // on NetBSD, 0 is P_ALL
17+
)
1518

1619
// blockUntilWaitable attempts to block until a call to p.Wait will
1720
// succeed immediately, and reports whether it has done so.
@@ -26,6 +29,8 @@ func (p *Process) blockUntilWaitable() (bool, error) {
2629
_, _, errno = syscall.Syscall9(syscall.SYS_WAIT6, _P_PID, uintptr(p.Pid), 0, 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0, 0, 0)
2730
} else if runtime.GOOS == "freebsd" && runtime.GOARCH == "arm" {
2831
_, _, errno = syscall.Syscall9(syscall.SYS_WAIT6, _P_PID, 0, uintptr(p.Pid), 0, 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0, 0)
32+
} else if runtime.GOOS == "netbsd" {
33+
_, _, errno = syscall.Syscall6(syscall.SYS_WAIT6, _P_PID_NETBSD, uintptr(p.Pid), 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0)
2934
} else {
3035
_, _, errno = syscall.Syscall6(syscall.SYS_WAIT6, _P_PID, uintptr(p.Pid), 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0)
3136
}

0 commit comments

Comments
 (0)