github.com/hernad/nomad@v1.6.112/drivers/nix/_executor/pty_unix.go (about) 1 //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris 2 // +build darwin dragonfly freebsd linux netbsd openbsd solaris 3 4 package executor 5 6 import ( 7 "fmt" 8 "io" 9 "os" 10 "strings" 11 "syscall" 12 13 "github.com/creack/pty" 14 "golang.org/x/sys/unix" 15 ) 16 17 func sessionCmdAttr(tty *os.File) *syscall.SysProcAttr { 18 return &syscall.SysProcAttr{ 19 Setsid: true, 20 Setctty: true, 21 } 22 } 23 24 func setTTYSize(w io.Writer, height, width int32) error { 25 f, ok := w.(*os.File) 26 if !ok { 27 return fmt.Errorf("attempted to resize a non-tty session") 28 } 29 30 return pty.Setsize(f, &pty.Winsize{ 31 Rows: uint16(height), 32 Cols: uint16(width), 33 }) 34 35 } 36 37 func isUnixEIOErr(err error) bool { 38 if err == nil { 39 return false 40 } 41 42 return strings.Contains(err.Error(), unix.EIO.Error()) 43 }