terminal: when closing term, pass status to closing
[src/xds/xds-server.git] / lib / xdsserver / terminal-ssh.go
index c275173..fcef4f9 100644 (file)
@@ -223,13 +223,15 @@ func (t *TermSSH) Open(sock *socketio.Socket, sessID string) (*xsapiv1.TerminalC
 
 // Close a terminal
 func (t *TermSSH) Close() (*xsapiv1.TerminalConfig, error) {
-       // nothing to do when not open
-       if t.termCfg.Status != xsapiv1.StatusTermOpen {
+       // nothing to do when not open or closing
+    if ! (t.termCfg.Status == xsapiv1.StatusTermOpen || t.termCfg.Status == xsapiv1.StatusTermClosing) {
                return &t.termCfg, nil
        }
 
        err := t.sshWS.Signal("SIGTERM")
 
+       t.termCfg.Status = xsapiv1.StatusTermClosing
+
        return &t.termCfg, err
 }