tailssh: fix platform SFTP session teardown

This commit is contained in:
世界
2026-07-09 11:20:02 +08:00
parent 9ac1e1b6ca
commit dbf960deff
2 changed files with 8 additions and 2 deletions
@@ -28,6 +28,7 @@ func (b *platformShellBackend) OpenSession(request shellRequest) (shellSession,
return &platformShellSession{
session: session,
master: master,
isPty: request.Term != "",
}, nil
}
@@ -38,6 +39,7 @@ func (b *platformShellBackend) Close() error {
type platformShellSession struct {
session adapter.ShellSession
master *os.File
isPty bool
}
func (s *platformShellSession) Read(p []byte) (int, error) {
@@ -53,8 +55,10 @@ func (s *platformShellSession) Close() error {
}
func (s *platformShellSession) CloseWrite() error {
// The platform owns the master fd lifecycle; rely on Close for teardown.
return nil
if s.isPty {
return nil
}
return syscall.Shutdown(int(s.master.Fd()), syscall.SHUT_WR)
}
func (s *platformShellSession) Resize(rows, cols uint16) error {
@@ -41,6 +41,8 @@ func StartSocketpairProcess(shell string, args, env []string, dir string, uid, g
if err != nil {
return nil, nil, E.Cause(err, "socketpair")
}
syscall.CloseOnExec(fds[0])
syscall.CloseOnExec(fds[1])
childFile := os.NewFile(uintptr(fds[1]), "socketpair-child")
cmd := exec.Command(shell)
cmd.Args = args