aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/export_linux_test.go
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2024-03-17 01:02:16 +1100
committerJoel Sing <joel@sing.id.au>2024-03-22 04:41:27 +0000
commitac0b2f95a5f25e9e331352c93e38f9b29bee9ccc (patch)
treef07e5dd85b8ba3c7e7379acf8b74c12eaabd9204 /src/syscall/export_linux_test.go
parent4f0408a3a205a88624dced4b188e11dd429bc3ad (diff)
downloadgo-ac0b2f95a5f25e9e331352c93e38f9b29bee9ccc.tar.xz
syscall: export Tc{get,set}pgrp for testing
Provide appropriate implementations of Tc{get,set}pgrp and export these for use in the TestForeground* tests in exec_unix_test.go. This avoids calling ioctl via syscall.Syscall on BSDs. Fixes #59667 Updates #63900 Change-Id: Ice4dcedae1f0931c026bddf33043d3864a52d44e Reviewed-on: https://go-review.googlesource.com/c/go/+/572155 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Joel Sing <joel@sing.id.au>
Diffstat (limited to 'src/syscall/export_linux_test.go')
-rw-r--r--src/syscall/export_linux_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/syscall/export_linux_test.go b/src/syscall/export_linux_test.go
index 3aa877cfe3..9bcf73e771 100644
--- a/src/syscall/export_linux_test.go
+++ b/src/syscall/export_linux_test.go
@@ -4,6 +4,10 @@
package syscall
+import (
+ "unsafe"
+)
+
var (
RawSyscallNoError = rawSyscallNoError
ForceClone3 = &forceClone3
@@ -12,3 +16,19 @@ var (
const (
Sys_GETEUID = sys_GETEUID
)
+
+func Tcgetpgrp(fd int) (pgid int32, err error) {
+ _, _, errno := Syscall6(SYS_IOCTL, uintptr(fd), uintptr(TIOCGPGRP), uintptr(unsafe.Pointer(&pgid)), 0, 0, 0)
+ if errno != 0 {
+ return -1, errno
+ }
+ return pgid, nil
+}
+
+func Tcsetpgrp(fd int, pgid int32) (err error) {
+ _, _, errno := Syscall6(SYS_IOCTL, uintptr(fd), uintptr(TIOCSPGRP), uintptr(unsafe.Pointer(&pgid)), 0, 0, 0)
+ if errno != 0 {
+ return errno
+ }
+ return nil
+}