mirror of
https://github.com/golang/go
synced 2024-11-17 18:44:44 -07:00
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 3323ceb782/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 <bcmills@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
4a4de14166
commit
9ec69908aa
@ -11,7 +11,10 @@ import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
const _P_PID = 0
|
||||
const (
|
||||
_P_PID = 0 // everywhere except for NetBSD?
|
||||
_P_PID_NETBSD = 1 // on NetBSD, 0 is P_ALL
|
||||
)
|
||||
|
||||
// blockUntilWaitable attempts to block until a call to p.Wait will
|
||||
// succeed immediately, and reports whether it has done so.
|
||||
@ -26,6 +29,8 @@ func (p *Process) blockUntilWaitable() (bool, error) {
|
||||
_, _, errno = syscall.Syscall9(syscall.SYS_WAIT6, _P_PID, uintptr(p.Pid), 0, 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0, 0, 0)
|
||||
} else if runtime.GOOS == "freebsd" && runtime.GOARCH == "arm" {
|
||||
_, _, errno = syscall.Syscall9(syscall.SYS_WAIT6, _P_PID, 0, uintptr(p.Pid), 0, 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0, 0)
|
||||
} else if runtime.GOOS == "netbsd" {
|
||||
_, _, errno = syscall.Syscall6(syscall.SYS_WAIT6, _P_PID_NETBSD, uintptr(p.Pid), 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0)
|
||||
} else {
|
||||
_, _, errno = syscall.Syscall6(syscall.SYS_WAIT6, _P_PID, uintptr(p.Pid), 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user