From: Clément Bénier Date: Tue, 14 Aug 2018 09:37:32 +0000 (+0200) Subject: terminal: when closing term, pass status to closing X-Git-Tag: 5.99.5~5 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=f223efc5e5a08764cf9f78fb5f38917ed949407f;p=src%2Fxds%2Fxds-server.git terminal: when closing term, pass status to closing status in return TerminalConfig is still opened when a term is closed Change-Id: Idacb67607ca32bfe35738d86e784512cb7758b02 Signed-off-by: Clément Bénier --- diff --git a/lib/xdsserver/terminal-ssh.go b/lib/xdsserver/terminal-ssh.go index c275173..fcef4f9 100644 --- a/lib/xdsserver/terminal-ssh.go +++ b/lib/xdsserver/terminal-ssh.go @@ -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 } diff --git a/lib/xsapiv1/targets.go b/lib/xsapiv1/targets.go index 793724a..bae36f9 100644 --- a/lib/xsapiv1/targets.go +++ b/lib/xsapiv1/targets.go @@ -65,6 +65,8 @@ const ( StatusTermOpen = "Open" // StatusTermClose Close state StatusTermClose = "Close" + // StatusTermClosing Closing state + StatusTermClosing = "Closing" // TerminalInEvent Event send in WS when characters are sent (stdin) TerminalInEvent = "term:input"