aboutsummaryrefslogtreecommitdiff
path: root/src/syscall
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2020-11-03 02:11:51 +1100
committerJoel Sing <joel@sing.id.au>2020-11-13 13:56:34 +0000
commit31f71506d7026595be76713af25197a8c0022ac8 (patch)
treefda9d6175e2f2fa14d3596771a156ddd54c0ea31 /src/syscall
parent30ba7980932dfb7ec6660ee929b4e1982256285f (diff)
downloadgo-31f71506d7026595be76713af25197a8c0022ac8.tar.gz
go-31f71506d7026595be76713af25197a8c0022ac8.zip
syscall: use correct type for TIOCSPGRP/TIOCGPGRP
These ioctls take a pid_t (generally a C integer aka int32) and not an int64 - we currently get away with this on little endian 64 bit platforms, since the bytes fall into the correct place, however this breaks on big endian 64 bit platforms (like openbsd/mips64). Update #40995 Change-Id: I622a0543fd562d97f76a7376a84fd2641e6d6a24 Reviewed-on: https://go-review.googlesource.com/c/go/+/267605 Trust: Joel Sing <joel@sing.id.au> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/syscall')
-rw-r--r--src/syscall/exec_bsd.go6
-rw-r--r--src/syscall/exec_unix_test.go4
2 files changed, 7 insertions, 3 deletions
diff --git a/src/syscall/exec_bsd.go b/src/syscall/exec_bsd.go
index af6c836961..b297db96cc 100644
--- a/src/syscall/exec_bsd.go
+++ b/src/syscall/exec_bsd.go
@@ -117,14 +117,16 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
}
if sys.Foreground {
- pgrp := sys.Pgid
+ // This should really be pid_t, however _C_int (aka int32) is
+ // generally equivalent.
+ pgrp := _C_int(sys.Pgid)
if pgrp == 0 {
r1, _, err1 = RawSyscall(SYS_GETPID, 0, 0, 0)
if err1 != 0 {
goto childerror
}
- pgrp = int(r1)
+ pgrp = _C_int(r1)
}
// Place process group in foreground.
diff --git a/src/syscall/exec_unix_test.go b/src/syscall/exec_unix_test.go
index 4431f7fc90..d6b6f51fa6 100644
--- a/src/syscall/exec_unix_test.go
+++ b/src/syscall/exec_unix_test.go
@@ -172,7 +172,9 @@ func TestForeground(t *testing.T) {
t.Skipf("Can't test Foreground. Couldn't open /dev/tty: %s", err)
}
- fpgrp := 0
+ // This should really be pid_t, however _C_int (aka int32) is generally
+ // equivalent.
+ fpgrp := int32(0)
errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, uintptr(unsafe.Pointer(&fpgrp)))
if errno != 0 {