mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Kill shell process by pid on Windows (#411)
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
parent
5af12bdbbd
commit
af24da976b
@ -159,7 +159,7 @@ export class ShellSession extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected exit(code = 1000) {
|
protected exit(code = 1000) {
|
||||||
this.websocket.close(code)
|
if (this.websocket.readyState == this.websocket.OPEN) this.websocket.close(code)
|
||||||
this.emit('exit')
|
this.emit('exit')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,12 +179,25 @@ export class ShellSession extends EventEmitter {
|
|||||||
|
|
||||||
protected exitProcessOnWebsocketClose() {
|
protected exitProcessOnWebsocketClose() {
|
||||||
this.websocket.on("close", () => {
|
this.websocket.on("close", () => {
|
||||||
if (this.shellProcess) {
|
this.killShellProcess()
|
||||||
this.shellProcess.kill();
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected killShellProcess(){
|
||||||
|
if(this.running) {
|
||||||
|
// On 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) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.shellProcess.kill()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected sendResponse(msg: string) {
|
protected sendResponse(msg: string) {
|
||||||
this.websocket.send("1" + Buffer.from(msg).toString("base64"))
|
this.websocket.send("1" + Buffer.from(msg).toString("base64"))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user