File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1776,7 +1776,8 @@ static void AtExit() {
17761776
17771777
17781778static void SignalExit (int signal) {
1779- ev_unloop (EV_DEFAULT_ EVUNLOOP_ALL );
1779+ AtExit ();
1780+ exit (1 );
17801781}
17811782
17821783
Original file line number Diff line number Diff line change 1+ // This test is to assert that we can SIGINT a script which loops forever.
2+ // ref: http://groups.google.com/group/nodejs-dev/browse_thread/thread/e20f2f8df0296d3f
3+ var common = require ( '../common' ) ;
4+ var assert = require ( 'assert' ) ;
5+ var spawn = require ( 'child_process' ) . spawn ;
6+
7+ console . log ( "start" ) ;
8+
9+ var c = spawn ( process . execPath , [ '-e' , 'while(true) { console.log("hi"); }' ] ) ;
10+
11+ var sentKill = false ;
12+ var gotChildExit = true ;
13+
14+ c . stdout . on ( 'data' , function ( s ) {
15+ // Prevent race condition:
16+ // Wait for the first bit of output from the child process
17+ // so that we're sure that it's in the V8 event loop and not
18+ // just in the startup phase of execution.
19+ if ( ! sentKill ) {
20+ c . kill ( 'SIGINT' )
21+ console . log ( "SIGINT infinite-loop.js" ) ;
22+ sentKill = true ;
23+ }
24+ } ) ;
25+
26+ c . on ( 'exit' , function ( code ) {
27+ assert . ok ( code !== 0 ) ;
28+ console . log ( "killed infinite-loop.js" ) ;
29+ gotChildExit = true ;
30+ } ) ;
31+
32+ process . on ( 'exit' , function ( ) {
33+ assert . ok ( sentKill ) ;
34+ assert . ok ( gotChildExit ) ;
35+ } ) ;
36+
You can’t perform that action at this time.
0 commit comments