Closed ThisGuyCodes closed 5 years ago
Can you provide small code reproducible?
package main
import "github.com/mattn/go-tty"
func main() {
tty.Open()
}
go run main.go &
Probably, it's not issue of go-tty, but if you want to run tasks in background, how about to ignore the signal?
signal.Ignore(syscall.SIGTTOU)
On second thought, maybe it makes more sense for the calling process to be responsible for this.
I will say that it's not intuitive that Open()
writes to the tty config.
tty.Open()
causes the calling process to suspend withSIGTTOU
on Linux if the caller is not in the foreground. Specifically the ioctl termios write is what hangs.Ideally this would instead return an error.
I attempted a prototype to catch this signal with
signal.Notify()
but it seems the signal isn't actually being sent until the process is in the foreground? Not sure.Alternatively is there a way to predict that this will happen? Some way of reading if the process is in the foreground?