tty_unix.go

 1//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || aix || zos
 2// +build darwin dragonfly freebsd linux netbsd openbsd solaris aix zos
 3
 4package uv
 5
 6import (
 7	"os"
 8	"os/signal"
 9	"syscall"
10)
11
12func openTTY() (inTty, outTty *os.File, err error) {
13	f, err := os.OpenFile("/dev/tty", os.O_RDWR, 0)
14	if err != nil {
15		return nil, nil, err
16	}
17	return f, f, nil
18}
19
20func suspend() (err error) {
21	// Send SIGTSTP to the entire process group.
22	c := make(chan os.Signal, 1)
23	signal.Notify(c, syscall.SIGCONT)
24	err = syscall.Kill(0, syscall.SIGTSTP)
25	// blocks until a CONT happens...
26	<-c
27	return
28}