okami.mom/ultraviolet
git clone https://git.nkp.pet/okami.mom/ultraviolet
6ea2266
upstream
1//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || aix 2// +build darwin dragonfly freebsd linux netbsd openbsd solaris aix 3 4package uv 5 6import ( 7"context" 8"os" 9"os/signal" 10"syscall" 11 12"golang.org/x/sys/unix" 13) 14 15func openTTY () (inTty ,outTty * os.File ,err error ) { 16f ,err := os .OpenFile ("/dev/tty" ,os .O_RDWR ,0 ) 17if err != nil { 18return nil ,nil ,err //nolint:wrapcheck 19 } 20return f ,f ,nil 21} 22 23func suspend () (err error ) { 24// Send SIGTSTP to the entire process group. 25c := make (chan os.Signal ,1 ) 26signal .Notify (c ,syscall .SIGCONT ) 27err = syscall .Kill (0 ,syscall .SIGTSTP ) 28// blocks until a CONT happens... 29<- c 30return 31} 32 33func notifyWinch (c chan os.Signal ,sigs ... os.Signal ) { 34signal .Notify (c ,append (sigs ,unix .SIGWINCH )... ) 35} 36 37func notifyWinchContext (ctx context.Context ,sigs ... os.Signal ) (context.Context , context.CancelFunc ) { 38return signal .NotifyContext (ctx ,append (sigs ,unix .SIGWINCH )... ) 39}