Skip to content

Commit becc17e

Browse files
committed
[release-branch.go1.24] runtime: use WCLONE when waiting on pidfd test child
As of CL 650835, the pidfd test child no longer sends SIGCHLD on exit. Per clone(2), "If [the child termination] signal is specified as anything other than SIGCHLD, then the parent process must specify the __WALL or __WCLONE options when waiting for the child with wait(2)." Align with this requirement. For #71849. For #71828. Change-Id: I6a6a636c739e4a59abe1533fe429a433e8588939 Reviewed-on: https://go-review.googlesource.com/c/go/+/651415 Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Michael Pratt <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> (cherry picked from commit e1e65ae) Reviewed-on: https://go-review.googlesource.com/c/go/+/651476
1 parent d418e22 commit becc17e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/syscall/exec_linux.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,12 @@ func os_checkClonePidfd() error {
779779
var err error
780780
for {
781781
var status WaitStatus
782-
_, err = Wait4(int(pid), &status, 0, nil)
782+
// WCLONE is an untyped constant that sets bit 31, so
783+
// it cannot convert directly to int on 32-bit
784+
// GOARCHes. We must convert through another type
785+
// first.
786+
flags := uint(WCLONE)
787+
_, err = Wait4(int(pid), &status, int(flags), nil)
783788
if err != EINTR {
784789
break
785790
}
@@ -797,7 +802,7 @@ func os_checkClonePidfd() error {
797802

798803
for {
799804
const _P_PIDFD = 3
800-
_, _, errno = Syscall6(SYS_WAITID, _P_PIDFD, uintptr(pidfd), 0, WEXITED, 0, 0)
805+
_, _, errno = Syscall6(SYS_WAITID, _P_PIDFD, uintptr(pidfd), 0, WEXITED | WCLONE, 0, 0)
801806
if errno != EINTR {
802807
break
803808
}

0 commit comments

Comments
 (0)