@@ -21,9 +21,15 @@ type impl struct {
21
21
22
22
// Slave is the slave PTY file descriptor.
23
23
Slave * os.File
24
+ }
25
+
26
+ func (i * impl ) IsZero () bool {
27
+ return i .Master == nil && i .Slave == nil
28
+ }
24
29
25
- // Name is the name of the slave PTY.
26
- Name string
30
+ // Name returns the name of the slave PTY.
31
+ func (i * impl ) Name () string {
32
+ return i .Slave .Name ()
27
33
}
28
34
29
35
// Read implements ptyInterface.
@@ -60,10 +66,13 @@ func (i *impl) Resize(w int, h int) (rErr error) {
60
66
}
61
67
62
68
func (i * impl ) start (c * exec.Cmd ) error {
63
- c .Stdin , c .Stdout , c .Stderr : = i .Slave , i .Slave , i .Slave
69
+ c .Stdin , c .Stdout , c .Stderr = i .Slave , i .Slave , i .Slave
64
70
if c .SysProcAttr == nil {
65
71
c .SysProcAttr = & syscall.SysProcAttr {}
66
72
}
73
+ c .SysProcAttr .Setctty = true
74
+ c .SysProcAttr .Setsid = true
75
+ return c .Start ()
67
76
}
68
77
69
78
func newPty (_ Context , _ string , win Window , modes ssh.TerminalModes ) (_ impl , rErr error ) {
@@ -83,7 +92,7 @@ func newPty(_ Context, _ string, win Window, modes ssh.TerminalModes) (_ impl, r
83
92
return impl {}, err
84
93
}
85
94
86
- return impl {Master : ptm , Slave : pts , Name : pts . Name () }, rErr
95
+ return impl {Master : ptm , Slave : pts }, rErr
87
96
}
88
97
89
98
func applyTerminalModesToFd (fd uintptr , width int , height int , modes ssh.TerminalModes ) error {
0 commit comments