cmd.Stop()
- errno = syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, uintptr(unsafe.Pointer(&fpgrp)))
- if errno != 0 {
- t.Fatalf("TIOCSPGRP failed with error code: %s", errno)
- }
+ // This call fails on darwin/arm64. The failure doesn't matter, though.
+ // This is just best effort.
+ syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, uintptr(unsafe.Pointer(&fpgrp)))
}
func TestForegroundSignal(t *testing.T) {
}
defer tty.Close()
+ // 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 {
+ t.Fatalf("TIOCGPGRP failed with error code: %s", errno)
+ }
+
+ if fpgrp == 0 {
+ t.Fatalf("Foreground process group is zero")
+ }
+
+ defer func() {
+ signal.Ignore(syscall.SIGTTIN, syscall.SIGTTOU)
+ syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, uintptr(unsafe.Pointer(&fpgrp)))
+ signal.Reset()
+ }()
+
ch1 := make(chan os.Signal, 1)
ch2 := make(chan bool)
signal.Notify(ch1, syscall.SIGTTIN, syscall.SIGTTOU)
defer signal.Stop(ch1)
+ cmd := create(t)
+
go func() {
- cmd := create(t)
cmd.proc.SysProcAttr = &syscall.SysProcAttr{
Ctty: int(tty.Fd()),
Foreground: true,