Skip to content

Commit

Permalink
modified SIGINT handling #3570 (#3602)
Browse files Browse the repository at this point in the history
* Updated SIGINT handler based on comment from #3570

Signed-off-by: jayasankar <jayasankar.m@gmail.com>
  • Loading branch information
Jayasankar-m authored and boneskull committed Dec 14, 2018
1 parent 6160a6a commit 3d3e833
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/cli/run-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,15 @@ 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();

// 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'));
});
};

Expand Down

0 comments on commit 3d3e833

Please sign in to comment.