Browse Source

fix: handle SIGINT and SIGTERM from the Electron CLI helper (#13889)

Fixes #12840
trop[bot] 6 years ago
parent
commit
13d3a055fa
1 changed files with 11 additions and 0 deletions
  1. 11 0
      npm/cli.js

+ 11 - 0
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')