Skip to content

Commit 9208ed3

Browse files
committed
os: fix blockUntilWaitable on freebsd/{386,arm}
The previous fix was wrong because it had two misunderstandings on freebsd32 calling convention like the following: - 32-bit id1 implies that it is the upper half of 64-bit id, indeed it depends on machine endianness. - 32-bit ARM calling convension doesn't conform to freebsd32_args, indeed it does. This change fixes the bugs and makes blockUntilWaitable work correctly on freebsd/{386,arm}. Fixes #16064. Change-Id: I820c6d01d59a43ac4f2ab381f757c03b14bca75e Reviewed-on: https://go-review.googlesource.com/24064 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent af0fc83 commit 9208ed3

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/os/wait_wait6.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,20 @@ const _P_PID = 0
1818
// It does not actually call p.Wait.
1919
func (p *Process) blockUntilWaitable() (bool, error) {
2020
var errno syscall.Errno
21+
// The arguments on 32-bit FreeBSD look like the following:
22+
// - freebsd32_wait6_args{ idtype, id1, id2, status, options, wrusage, info } or
23+
// - freebsd32_wait6_args{ idtype, pad, id1, id2, status, options, wrusage, info } when PAD64_REQUIRED=1 on ARM, MIPS or PowerPC
2124
if runtime.GOARCH == "386" {
22-
// The arguments on 32-bit FreeBSD except ARM look
23-
// like the following:
24-
// - freebsd32_wait6_args{ idtype, id1, id2, status, options, wrusage, info } or
25-
// - freebsd32_wait6_args{ idtype, pad, id1, id2, status, options, wrusage, info } when PAD64_REQUIRED=1 on MIPS or PowerPC
26-
_, _, errno = syscall.Syscall9(syscall.SYS_WAIT6, _P_PID, 0, uintptr(p.Pid), 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0, 0, 0)
25+
_, _, errno = syscall.Syscall9(syscall.SYS_WAIT6, _P_PID, uintptr(p.Pid), 0, 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0, 0, 0)
26+
} else if runtime.GOARCH == "arm" {
27+
_, _, errno = syscall.Syscall9(syscall.SYS_WAIT6, _P_PID, 0, uintptr(p.Pid), 0, 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0, 0)
2728
} else {
2829
_, _, errno = syscall.Syscall6(syscall.SYS_WAIT6, _P_PID, uintptr(p.Pid), 0, syscall.WEXITED|syscall.WNOWAIT, 0, 0)
2930
}
3031
if errno != 0 {
3132
// The wait6 system call is supported only on FreeBSD
3233
// 9.3 and above, so it may return an ENOSYS error.
33-
// Also the system call may return an ECHILD error
34-
// when the child process has not finished the
35-
// transformation using execve system call.
36-
// In both cases, we just leave the care of child
37-
// process to the following wait4 system call in
38-
// Process.wait.
39-
if errno == syscall.ENOSYS || errno == syscall.ECHILD {
34+
if errno == syscall.ENOSYS {
4035
return false, nil
4136
}
4237
return false, NewSyscallError("wait6", errno)

0 commit comments

Comments
 (0)