github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/drivers/shared/executor/pty_unix.go (about) 1 // +build darwin dragonfly freebsd linux netbsd openbsd solaris 2 3 package executor 4 5 import ( 6 "fmt" 7 "io" 8 "os" 9 "strings" 10 "syscall" 11 12 "github.com/kr/pty" 13 "golang.org/x/sys/unix" 14 ) 15 16 func sessionCmdAttr(tty *os.File) *syscall.SysProcAttr { 17 return &syscall.SysProcAttr{ 18 Setsid: true, 19 Setctty: true, 20 Ctty: int(tty.Fd()), 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 }