Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

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

Signed-off-by: jayasankar <jayasankar.m@gmail.com>
  • Loading branch information
Jayasankar-m authored and boneskull committed Dec 14, 2018
1 parent d0f256d commit a309ea3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/cli/run-helpers.js
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 a309ea3

Please sign in to comment.