fix(CLI): Fix SIGINT signal handling

This commit is contained in:
Mariusz Nowak 2021-07-07 15:33:17 +02:00 committed by Mariusz Nowak
parent b86f8cd715
commit c5a3f6907a

View File

@ -55,8 +55,11 @@ process.once('uncaughtException', (error) => {
});
});
process.on('SIGINT', () => {
process.once('SIGINT', () => {
clearTimeout(keepAliveTimer);
// If there's another SIGINT listener (command that works as deamon or reads stdin input)
// then let the other listener decide how process will exit
const isOtherSigintListener = Boolean(process.listenerCount('SIGINT'));
if (
commandSchema &&
!hasTelemetryBeenReported &&
@ -74,7 +77,7 @@ process.on('SIGINT', () => {
});
storeTelemetryLocally({ ...telemetryPayload, outcome: 'interrupt' });
}
process.exit(1);
if (!isOtherSigintListener) process.exit(130);
});
const processSpanPromise = (async () => {