d4f385d6e1
Upgrade to golang 1.15 Starting with golang 1.5, setting Ctty value result in `Setctty set but Ctty not valid in child` error, as part of https://github.com/golang/go/issues/29458 . This commit lifts the fix in https://github.com/creack/pty/pull/97 .
43 lines
688 B
Go
43 lines
688 B
Go
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
|
|
|
package executor
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
"strings"
|
|
"syscall"
|
|
|
|
"github.com/kr/pty"
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func sessionCmdAttr(tty *os.File) *syscall.SysProcAttr {
|
|
return &syscall.SysProcAttr{
|
|
Setsid: true,
|
|
Setctty: true,
|
|
}
|
|
}
|
|
|
|
func setTTYSize(w io.Writer, height, width int32) error {
|
|
f, ok := w.(*os.File)
|
|
if !ok {
|
|
return fmt.Errorf("attempted to resize a non-tty session")
|
|
}
|
|
|
|
return pty.Setsize(f, &pty.Winsize{
|
|
Rows: uint16(height),
|
|
Cols: uint16(width),
|
|
})
|
|
|
|
}
|
|
|
|
func isUnixEIOErr(err error) bool {
|
|
if err == nil {
|
|
return false
|
|
}
|
|
|
|
return strings.Contains(err.Error(), unix.EIO.Error())
|
|
}
|