diff options
author | Joel Sing <joel@sing.id.au> | 2021-05-30 01:46:19 +1000 |
---|---|---|
committer | Joel Sing <joel@sing.id.au> | 2021-08-16 10:46:11 +0000 |
commit | 3d679c6554d5b282154caa717567ad8353a8bc71 (patch) | |
tree | adf3004755fd51d9fa6052fc97661003c1e1464c /src/syscall | |
parent | fcdc3c098cd016af9ba5e626bd4525575bb984f2 (diff) | |
download | go-3d679c6554d5b282154caa717567ad8353a8bc71.tar.gz go-3d679c6554d5b282154caa717567ad8353a8bc71.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).
This is the same fix as CL 267605, however for libc based exec.
Updates #36435
Change-Id: I01ae4905cba5e1f8725fa6cb8c35403c511534b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/334881
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/syscall')
-rw-r--r-- | src/syscall/exec_libc2.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/syscall/exec_libc2.go b/src/syscall/exec_libc2.go index b999754c2e..bd98109d07 100644 --- a/src/syscall/exec_libc2.go +++ b/src/syscall/exec_libc2.go @@ -117,14 +117,15 @@ 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(abi.FuncPCABI0(libc_getpid_trampoline), 0, 0, 0) if err1 != 0 { goto childerror } - - pgrp = int(r1) + pgrp = _C_int(r1) } // Place process group in foreground. |