From 84fadfe936f72453967264a1f7e5fe69f7e9973e Mon Sep 17 00:00:00 2001 From: jayasankar Date: Wed, 12 Dec 2018 22:51:38 +0530 Subject: [PATCH] modified to reraise SIGINT signal once #3570 Signed-off-by: jayasankar --- lib/cli/run-helpers.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/cli/run-helpers.js b/lib/cli/run-helpers.js index dc08a63ca1..89aa7a4674 100644 --- a/lib/cli/run-helpers.js +++ b/lib/cli/run-helpers.js @@ -196,15 +196,19 @@ exports.singleRun = (mocha, {files = [], exit = false} = {}) => { mocha.files = files; const runner = mocha.run(exit ? exitMocha : exitMochaLater); - process.on('SIGINT', () => { - debug('aborting runner'); - runner.abort(); - - // This is a hack: - // Instead of `process.exit(130)`, set runner.failures to 130 (exit code for SIGINT) - // The amount of failures will be emitted as error code later - runner.failures = 130; - setImmediate(() => process.kill(process.pid, 'SIGINT')); + process.on('SIGINT', function forceStop() { + if (forceStop.lock === undefined) { + forceStop.lock = true; + debug('aborting runner'); + runner.abort(); + + // This is a hack: + // Instead of `process.exit(130)`, set runner.failures to 130 (exit code for SIGINT) + // The amount of failures will be emitted as error code later + runner.failures = 130; + // Reraising the signal + setImmediate(() => process.kill(process.pid, 'SIGINT')); + } }); };