From 3d3e8337c323992a305fb66ae94354d448f623d3 Mon Sep 17 00:00:00 2001 From: Jayasankar Date: Fri, 14 Dec 2018 11:27:05 +0530 Subject: [PATCH] modified SIGINT handling #3570 (#3602) * Updated SIGINT handler based on comment from #3570 Signed-off-by: jayasankar --- lib/cli/run-helpers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cli/run-helpers.js b/lib/cli/run-helpers.js index d020768aed..e574e1fbd2 100644 --- a/lib/cli/run-helpers.js +++ b/lib/cli/run-helpers.js @@ -196,7 +196,7 @@ exports.singleRun = (mocha, {files = [], exit = false} = {}) => { mocha.files = files; const runner = mocha.run(exit ? exitMocha : exitMochaLater); - process.on('SIGINT', () => { + process.once('SIGINT', () => { debug('aborting runner'); runner.abort(); @@ -204,6 +204,7 @@ exports.singleRun = (mocha, {files = [], exit = false} = {}) => { // 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')); }); };