aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClément Bénier <clement.benier@iot.bzh>2018-08-14 11:37:32 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-08-20 13:33:39 +0000
commitf223efc5e5a08764cf9f78fb5f38917ed949407f (patch)
treeaa513265bd52662e40fa1ad0f2046e7459928b0d
parent8e18650d881cbf3d7016e10442e34096d7cca127 (diff)
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 <clement.benier@iot.bzh>
-rw-r--r--lib/xdsserver/terminal-ssh.go6
-rw-r--r--lib/xsapiv1/targets.go2
2 files changed, 6 insertions, 2 deletions
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"