Skip to content

Commit

Permalink
os/signal: use syscall.Wait4 directly in tests
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
4a6f656c committed Nov 1, 2023
1 parent 1a58fd0 commit 0aa2197
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/os/signal/signal_cgo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
}
Expand Down

0 comments on commit 0aa2197

Please sign in to comment.