From 7b6cdb274cb7f039a1a64ec53647cee4c0d01f7d Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Tue, 31 Dec 2019 13:01:37 +0100 Subject: [PATCH] fixed shell process not being killed on tab close --- terminus-core/src/components/splitTab.component.ts | 7 +++++++ terminus-terminal/src/services/sessions.service.ts | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/terminus-core/src/components/splitTab.component.ts b/terminus-core/src/components/splitTab.component.ts index be571971..8e1048b9 100644 --- a/terminus-core/src/components/splitTab.component.ts +++ b/terminus-core/src/components/splitTab.component.ts @@ -436,6 +436,13 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes this.splitAdjusted.next(spanner) } + destroy () { + super.destroy() + for (const x of this.getAllTabs()) { + x.destroy() + } + } + private attachTabView (tab: BaseTabComponent) { const ref = this.viewContainer.insert(tab.hostView) as EmbeddedViewRef // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion this.viewRefs.set(tab, ref) diff --git a/terminus-terminal/src/services/sessions.service.ts b/terminus-terminal/src/services/sessions.service.ts index 45ca11b9..410e39c0 100644 --- a/terminus-terminal/src/services/sessions.service.ts +++ b/terminus-terminal/src/services/sessions.service.ts @@ -255,15 +255,15 @@ export class Session extends BaseSession { await new Promise((resolve) => { this.kill('SIGTERM') setImmediate(() => { - if (!this.open) { - resolve() - } else { + try { + process.kill(this.pty.pid, 0) + // still alive setTimeout(() => { - if (this.open) { - this.kill('SIGKILL') - } + this.kill('SIGKILL') resolve() }, 1000) + } catch { + resolve() } }) })