From eb79ad4dab445f76ee7bf93288863a4e172bb93d Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Wed, 1 Aug 2018 04:44:04 +1000 Subject: [PATCH] fix: handle SIGINT and SIGTERM from the Electron CLI helper (#13867) Fixes #12840 --- npm/cli.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/npm/cli.js b/npm/cli.js index bfe2c11be3..48cdef8f19 100755 --- a/npm/cli.js +++ b/npm/cli.js @@ -8,3 +8,14 @@ var child = proc.spawn(electron, process.argv.slice(2), {stdio: 'inherit'}) child.on('close', function (code) { process.exit(code) }) + +const handleTerminationSignal = function (signal) { + process.on(signal, function signalHandler () { + if (!child.killed) { + child.kill(signal) + } + }) +} + +handleTerminationSignal('SIGINT') +handleTerminationSignal('SIGTERM')