mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
fix: remove killed check to allow multiple signals (#40667)
* fix: remove `killed` check to allow multiple signals * fix: signal forwarding
This commit is contained in:
@@ -5,7 +5,9 @@ const proc = require('child_process');
|
||||
const electron = require('./');
|
||||
|
||||
const child = proc.spawn(electron, process.argv.slice(2), { stdio: 'inherit', windowsHide: false });
|
||||
let childClosed = false;
|
||||
child.on('close', function (code, signal) {
|
||||
childClosed = true;
|
||||
if (code === null) {
|
||||
console.error(electron, 'exited with signal', signal);
|
||||
process.exit(1);
|
||||
@@ -15,7 +17,7 @@ child.on('close', function (code, signal) {
|
||||
|
||||
const handleTerminationSignal = function (signal) {
|
||||
process.on(signal, function signalHandler () {
|
||||
if (!child.killed) {
|
||||
if (!childClosed) {
|
||||
child.kill(signal);
|
||||
}
|
||||
});
|
||||
@@ -23,3 +25,4 @@ const handleTerminationSignal = function (signal) {
|
||||
|
||||
handleTerminationSignal('SIGINT');
|
||||
handleTerminationSignal('SIGTERM');
|
||||
handleTerminationSignal('SIGUSR2');
|
||||
|
||||
@@ -5,11 +5,15 @@ const utils = require('./lib/utils');
|
||||
const electronPath = utils.getAbsoluteElectronExec();
|
||||
|
||||
const child = cp.spawn(electronPath, process.argv.slice(2), { stdio: 'inherit' });
|
||||
child.on('close', (code) => process.exit(code));
|
||||
let childClosed = false;
|
||||
child.on('close', (code) => {
|
||||
childClosed = true;
|
||||
process.exit(code);
|
||||
});
|
||||
|
||||
const handleTerminationSignal = (signal) =>
|
||||
process.on(signal, () => {
|
||||
if (!child.killed) {
|
||||
if (!childClosed) {
|
||||
child.kill(signal);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user