1
0
mirror of https://github.com/golang/go synced 2024-09-28 22:14:28 -06:00

os/signal: use syscall.Wait4 directly in tests

Rather than using syscall.Syscall6 with SYS_WAIT4, use syscall.Wait4
directly.

Updates #59667

Change-Id: I50fea3b7d10003dbc632aafd5e170a9fe96d6f42
Reviewed-on: https://go-review.googlesource.com/c/go/+/538459
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Joel Sing 2023-10-29 02:07:01 +11:00
parent 1a58fd0fda
commit 0aa2197279

View File

@ -288,15 +288,14 @@ func runSessionLeader(t *testing.T, pause time.Duration) {
// Wait for stop.
var status syscall.WaitStatus
var errno syscall.Errno
for {
_, _, errno = syscall.Syscall6(syscall.SYS_WAIT4, uintptr(cmd.Process.Pid), uintptr(unsafe.Pointer(&status)), syscall.WUNTRACED, 0, 0, 0)
if errno != syscall.EINTR {
_, err = syscall.Wait4(cmd.Process.Pid, &status, syscall.WUNTRACED, nil)
if err != syscall.EINTR {
break
}
}
if errno != 0 {
return fmt.Errorf("error waiting for stop: %w", errno)
if err != nil {
return fmt.Errorf("error waiting for stop: %w", err)
}
if !status.Stopped() {
@ -305,7 +304,7 @@ func runSessionLeader(t *testing.T, pause time.Duration) {
// Take TTY.
pgrp := int32(syscall.Getpgrp()) // assume that pid_t is int32
_, _, errno = syscall.Syscall(syscall.SYS_IOCTL, ptyFD, syscall.TIOCSPGRP, uintptr(unsafe.Pointer(&pgrp)))
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, ptyFD, syscall.TIOCSPGRP, uintptr(unsafe.Pointer(&pgrp)))
if errno != 0 {
return fmt.Errorf("error setting tty process group: %w", errno)
}