From 4fe377590405d197dc9fd99e270e18ebac3de9a9 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Sun, 28 Oct 2018 19:18:42 +0100 Subject: [PATCH] fix(child processes): now run detached --- ts/smartshell.classes.smartshell.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ts/smartshell.classes.smartshell.ts b/ts/smartshell.classes.smartshell.ts index e08746b..b8703c7 100644 --- a/ts/smartshell.classes.smartshell.ts +++ b/ts/smartshell.classes.smartshell.ts @@ -21,6 +21,7 @@ export interface IExecResult { export interface IExecResultStreaming { childProcess: cp.ChildProcess; finalPromise: Promise; + kill: () => void; } // -- SmartShell -- @@ -70,7 +71,11 @@ export class Smartshell { if (streamingArg) { done.resolve({ childProcess: execChildProcess, - finalPromise: childProcessEnded.promise + finalPromise: childProcessEnded.promise, + kill: () => { + // this notation with the - kills the whole process group + process.kill(-execChildProcess.pid); + } }); }