Skip to content

Commit

Permalink
resolves mochajs#1393: kill children with more effort on SIGINT
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Hiller authored and tandrewnichols committed Dec 15, 2014
1 parent c2fc8a4 commit dc3177b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bin/mocha
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@ proc.on('exit', function (code, signal) {
}
});
});

// terminate children.
process.on('SIGINT', function () {
proc.kill('SIGINT'); // calls runner.abort()
proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die.
process.kill(process.pid, 'SIGINT');
});
5 changes: 5 additions & 0 deletions test/acceptance/misc/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ describe('exit', function(){
console.log('all done');
}, 2500)
})

it('should kill all processes when SIGINT received', function () {
// uncomment to test
//while (true) {}
});
})

0 comments on commit dc3177b

Please sign in to comment.