Skip to content

Commit

Permalink
refactor: bindHiddenSignalsHandler to handle exit
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Nov 26, 2023
1 parent 26e796b commit a88289d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/preflight.cts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ const bindHiddenSignalsHandler = (
) => {
type RelaySignals = typeof signals[number];
for (const signal of signals) {
process.on(signal, handler);
process.on(signal, function (receivedSignal) {

Check warning on line 13 in src/preflight.cts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Unexpected unnamed function

Check failure on line 13 in src/preflight.cts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Unexpected function expression
handler(receivedSignal);

/**
* Since we're setting a custom signal handler, we need to emulate the
* default behavior when there are no other handlers set
*/
if (process.listenerCount(signal) === 0) {
process.exit(128 + osConstants.signals[signal]);
}
});
}

/**
Expand Down Expand Up @@ -60,14 +70,6 @@ if (isMainThread) {
type: 'kill',
signal,
});

/**
* Since we're setting a custom signal handler, we need to emulate the
* default behavior when there are no other handlers set
*/
if (process.listenerCount(signal) === 0) {
process.exit(128 + osConstants.signals[signal]);
}
});
}
}

0 comments on commit a88289d

Please sign in to comment.