aboutsummaryrefslogtreecommitdiff
path: root/executor/pty_unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'executor/pty_unix.go')
-rw-r--r--executor/pty_unix.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/executor/pty_unix.go b/executor/pty_unix.go
new file mode 100644
index 0000000..2df23e3
--- /dev/null
+++ b/executor/pty_unix.go
@@ -0,0 +1,43 @@
+//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+
+package executor
+
+import (
+ "fmt"
+ "io"
+ "os"
+ "strings"
+ "syscall"
+
+ "github.com/creack/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())
+}