]> Cypherpunks repositories - gostls13.git/commitdiff
os/signal: pass *int32 to ioctl that expects pid_t
authorIan Lance Taylor <iant@golang.org>
Fri, 14 Oct 2022 23:19:11 +0000 (16:19 -0700)
committerBryan Mills <bcmills@google.com>
Mon, 17 Oct 2022 15:26:00 +0000 (15:26 +0000)
Fixes #56233

Change-Id: I1cf176bc2f39c5e41d5a390ec6893426cdd39be0
Reviewed-on: https://go-review.googlesource.com/c/go/+/443175
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/os/signal/signal_cgo_test.go

index 614d1490c5e32d81c971baac12163ba29bcb8dc5..5cfb00632d2073b9f6883b88693545650b3dca5b 100644 (file)
@@ -21,14 +21,14 @@ import (
        "runtime"
        "strconv"
        "syscall"
-       "unsafe"
        "testing"
        "time"
+       "unsafe"
 )
 
 const (
-       ptyFD     = 3  // child end of pty.
-       controlFD = 4  // child end of control pipe.
+       ptyFD     = 3 // child end of pty.
+       controlFD = 4 // child end of control pipe.
 )
 
 // TestTerminalSignal tests that read from a pseudo-terminal does not return an
@@ -279,7 +279,7 @@ func runSessionLeader(pause time.Duration) {
                }
 
                // Take TTY.
-               pgrp := syscall.Getpgrp()
+               pgrp := int32(syscall.Getpgrp()) // assume that pid_t is int32
                _, _, 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)
@@ -290,7 +290,7 @@ func runSessionLeader(pause time.Duration) {
                time.Sleep(pause)
 
                // Give TTY back.
-               pid := uint64(cmd.Process.Pid)
+               pid := int32(cmd.Process.Pid) // assume that pid_t is int32
                _, _, errno = syscall.Syscall(syscall.SYS_IOCTL, ptyFD, syscall.TIOCSPGRP, uintptr(unsafe.Pointer(&pid)))
                if errno != 0 {
                        return fmt.Errorf("error setting tty process group back: %w", errno)