From 86fff0defa29e982e126bf9fd61e9f6d65f70f84 Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Mon, 8 Jun 2020 15:21:38 +0300 Subject: [PATCH] Finetuning Signed-off-by: Lauri Nevala --- src/main/shell-session.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/shell-session.ts b/src/main/shell-session.ts index 97f3b19701..f8785e7cae 100644 --- a/src/main/shell-session.ts +++ b/src/main/shell-session.ts @@ -182,16 +182,24 @@ export class ShellSession extends EventEmitter { protected exitProcessOnWebsocketClose() { this.websocket.on("close", () => { - if (this.shellProcess) { - logger.debug("Killing shell process") + logger.debug("Killing shell process") + this.killShellProcess() + }) + } + + protected killShellProcess(){ + if(this.running) { + // For windows we need to kill the shell process by pid, since Lens won't respond after a while if using `this.shellProcess.kill()` + if (process.platform == "win32") { try { process.kill(this.shellProcess.pid) } catch(e) { logger.debug("Process id not exist") } - this.emit('exit') + } else { + this.shellProcess.kill() } - }) + } } protected sendResponse(msg: string) {