|
1 | 1 | var common = require('../common');
|
2 | 2 | var assert = require('assert');
|
| 3 | +var spawn = require('child_process').spawn; |
3 | 4 |
|
4 |
| -var childKilled = false, done = false, |
5 |
| - spawn = require('child_process').spawn, |
6 |
| - util = require('util'), |
7 |
| - child; |
8 |
| - |
9 |
| -var join = require('path').join; |
10 |
| - |
11 |
| -child = spawn(process.argv[0], [join(common.fixturesDir, 'should_exit.js')]); |
12 |
| -child.on('exit', function() { |
13 |
| - if (!done) childKilled = true; |
14 |
| -}); |
15 |
| - |
16 |
| -setTimeout(function() { |
17 |
| - console.log('Sending SIGINT'); |
| 5 | +var child = spawn(process.argv[0], [common.fixturesDir + '/should_exit.js']); |
| 6 | +child.stdout.once('data', function() { |
18 | 7 | child.kill('SIGINT');
|
19 |
| - setTimeout(function() { |
20 |
| - console.log('Chance has been given to die'); |
21 |
| - done = true; |
22 |
| - if (!childKilled) { |
23 |
| - // Cleanup |
24 |
| - console.log('Child did not die on SIGINT, sending SIGTERM'); |
25 |
| - child.kill('SIGTERM'); |
26 |
| - } |
27 |
| - }, 200); |
28 |
| -}, 200); |
29 |
| - |
30 |
| -process.on('exit', function() { |
31 |
| - assert.ok(childKilled); |
32 | 8 | });
|
| 9 | +child.on('exit', common.mustCall(function(exitCode, signalCode) { |
| 10 | + assert.equal(exitCode, null); |
| 11 | + assert.equal(signalCode, 'SIGINT'); |
| 12 | +})); |
0 commit comments