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:
Ruben R
2025-10-23 14:20:04 -05:00
committed by GitHub
parent 418b8235bc
commit 00e01e0e82
2 changed files with 10 additions and 3 deletions

View File

@@ -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');

View File

@@ -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);
}
});