]> Cypherpunks.ru repositories - gostls13.git/commitdiff
os/signal: use syscall.Wait4 directly in tests
authorJoel Sing <joel@sing.id.au>
Sat, 28 Oct 2023 15:07:01 +0000 (02:07 +1100)
committerJoel Sing <joel@sing.id.au>
Wed, 1 Nov 2023 07:10:32 +0000 (07:10 +0000)
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>

src/os/signal/signal_cgo_test.go

index 9e9a9fe52655803010c477d70c486486b1c151f6..0aaf38c221decd6b9bf2e305f4b7630b5179d5a3 100644 (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)
                }