mirror of https://github.com/lukechilds/node.git
Browse Source
Change sequential/test-signal-unregister so it doesn't use fixed timeouts for sending the signal and expecting the child to quit. Fixes: https://github.com/iojs/io.js/issues/1223 PR-URL: https://github.com/iojs/io.js/pull/1227 Reviewed-By: Johan Bergström <bugs@bergstroem.nu>v1.8.0-commit
Ben Noordhuis
10 years ago
2 changed files with 8 additions and 27 deletions
@ -1,32 +1,12 @@ |
|||||
var common = require('../common'); |
var common = require('../common'); |
||||
var assert = require('assert'); |
var assert = require('assert'); |
||||
|
var spawn = require('child_process').spawn; |
||||
|
|
||||
var childKilled = false, done = false, |
var child = spawn(process.argv[0], [common.fixturesDir + '/should_exit.js']); |
||||
spawn = require('child_process').spawn, |
child.stdout.once('data', function() { |
||||
util = require('util'), |
|
||||
child; |
|
||||
|
|
||||
var join = require('path').join; |
|
||||
|
|
||||
child = spawn(process.argv[0], [join(common.fixturesDir, 'should_exit.js')]); |
|
||||
child.on('exit', function() { |
|
||||
if (!done) childKilled = true; |
|
||||
}); |
|
||||
|
|
||||
setTimeout(function() { |
|
||||
console.log('Sending SIGINT'); |
|
||||
child.kill('SIGINT'); |
child.kill('SIGINT'); |
||||
setTimeout(function() { |
|
||||
console.log('Chance has been given to die'); |
|
||||
done = true; |
|
||||
if (!childKilled) { |
|
||||
// Cleanup
|
|
||||
console.log('Child did not die on SIGINT, sending SIGTERM'); |
|
||||
child.kill('SIGTERM'); |
|
||||
} |
|
||||
}, 200); |
|
||||
}, 200); |
|
||||
|
|
||||
process.on('exit', function() { |
|
||||
assert.ok(childKilled); |
|
||||
}); |
}); |
||||
|
child.on('exit', common.mustCall(function(exitCode, signalCode) { |
||||
|
assert.equal(exitCode, null); |
||||
|
assert.equal(signalCode, 'SIGINT'); |
||||
|
})); |
||||
|
Loading…
Reference in new issue