summaryrefslogtreecommitdiffhomepage
path: root/tempfork/gliderlabs/ssh/session.go
diff options
context:
space:
mode:
Diffstat (limited to 'tempfork/gliderlabs/ssh/session.go')
-rw-r--r--tempfork/gliderlabs/ssh/session.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/tempfork/gliderlabs/ssh/session.go b/tempfork/gliderlabs/ssh/session.go
index a7a9a3eeb..ef068355e 100644
--- a/tempfork/gliderlabs/ssh/session.go
+++ b/tempfork/gliderlabs/ssh/session.go
@@ -188,7 +188,12 @@ func (sess *session) Exit(code int) error {
if err != nil {
return err
}
- return sess.Close()
+ // Don't close the channel here. Per RFC 4254 section 6.10, the exit-status
+ // message should be sent before the channel is closed. By not closing immediately,
+ // we allow the session handler to complete any remaining I/O operations (like
+ // flushing output and sending EOF via CloseWrite) before the channel is closed
+ // by the request handler's cleanup code.
+ return nil
}
func (sess *session) User() string {
@@ -273,6 +278,7 @@ func (sess *session) handleRequests(reqs <-chan *gossh.Request) {
go func() {
sess.handler(sess)
sess.Exit(0)
+ sess.Close()
}()
case "subsystem":
if sess.handled {
@@ -307,6 +313,7 @@ func (sess *session) handleRequests(reqs <-chan *gossh.Request) {
go func() {
handler(sess)
sess.Exit(0)
+ sess.Close()
}()
case "env":
if sess.handled {