Skip to content

Commit ccd9a55

Browse files
committed
os: use waitid to avoid wait/kill race on darwin
This change is a followup to https://go-review.googlesource.com/23967 for Darwin. Updates #13987. Updates #16028. Change-Id: Ib1fb9f957fafd0f91da6fceea56620e29ad82b00 Reviewed-on: https://go-review.googlesource.com/24020 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 84d8aff commit ccd9a55

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/os/wait_unimp.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build darwin dragonfly freebsd nacl netbsd openbsd solaris
5+
// +build dragonfly freebsd nacl netbsd openbsd solaris
66

77
package os
88

src/os/wait_linux.go renamed to src/os/wait_waitid.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
// +build darwin linux
6+
57
package os
68

79
import (
@@ -16,8 +18,11 @@ const _P_PID = 1
1618
// succeed immediately, and returns whether it has done so.
1719
// It does not actually call p.Wait.
1820
func (p *Process) blockUntilWaitable() (bool, error) {
19-
// waitid expects a pointer to a siginfo_t, which is 128 bytes
20-
// on all systems. We don't care about the values it returns.
21+
// The waitid system call expects a pointer to a siginfo_t,
22+
// which is 128 bytes on all GNU/Linux systems.
23+
// On Darwin, it requires greater than or equal to 64 bytes
24+
// for darwin/{386,arm} and 104 bytes for darwin/amd64.
25+
// We don't care about the values it returns.
2126
var siginfo [128]byte
2227
psig := &siginfo[0]
2328
_, _, e := syscall.Syscall6(syscall.SYS_WAITID, _P_PID, uintptr(p.Pid), uintptr(unsafe.Pointer(psig)), syscall.WEXITED|syscall.WNOWAIT, 0, 0)

0 commit comments

Comments
 (0)