gitlab.com/Raven-IO/raven-delve@v1.22.4/pkg/proc/native/proc_unix.go (about) 1 //go:build !windows 2 3 package native 4 5 import ( 6 "fmt" 7 "os" 8 "os/exec" 9 10 isatty "github.com/mattn/go-isatty" 11 ) 12 13 func attachProcessToTTY(process *exec.Cmd, tty string) (*os.File, error) { 14 f, err := os.OpenFile(tty, os.O_RDWR, 0) 15 if err != nil { 16 return nil, err 17 } 18 if !isatty.IsTerminal(f.Fd()) { 19 f.Close() 20 return nil, fmt.Errorf("%s is not a terminal", f.Name()) 21 } 22 process.Stdin = f 23 process.Stdout = f 24 process.Stderr = f 25 process.SysProcAttr.Setpgid = false 26 process.SysProcAttr.Setsid = true 27 process.SysProcAttr.Setctty = true 28 29 return f, nil 30 }