2010-12-05 07:20:34 +08:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
2009-10-06 08:56:33 +08:00
|
|
|
|
2010-12-05 06:45:52 +08:00
|
|
|
console.log('process.pid: ' + process.pid);
|
2009-10-15 05:56:12 +08:00
|
|
|
|
|
|
|
var first = 0,
|
|
|
|
second = 0;
|
|
|
|
|
2010-12-05 06:45:52 +08:00
|
|
|
process.addListener('SIGUSR1', function() {
|
|
|
|
console.log('Interrupted by SIGUSR1');
|
2009-10-15 05:56:12 +08:00
|
|
|
first += 1;
|
|
|
|
});
|
|
|
|
|
2010-12-05 06:45:52 +08:00
|
|
|
process.addListener('SIGUSR1', function() {
|
2009-10-15 05:56:12 +08:00
|
|
|
second += 1;
|
2010-12-05 06:45:52 +08:00
|
|
|
setTimeout(function() {
|
|
|
|
console.log('End.');
|
2009-10-15 05:56:12 +08:00
|
|
|
process.exit(0);
|
|
|
|
}, 5);
|
|
|
|
});
|
|
|
|
|
2010-12-05 08:11:57 +08:00
|
|
|
var i = 0;
|
2010-12-05 06:45:52 +08:00
|
|
|
setInterval(function() {
|
|
|
|
console.log('running process...' + ++i);
|
2009-10-15 05:56:12 +08:00
|
|
|
|
|
|
|
if (i == 5) {
|
2010-12-05 06:45:52 +08:00
|
|
|
process.kill(process.pid, 'SIGUSR1');
|
2009-10-15 05:56:12 +08:00
|
|
|
}
|
|
|
|
}, 1);
|
|
|
|
|
|
|
|
|
2010-12-05 06:45:52 +08:00
|
|
|
process.addListener('exit', function() {
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal(1, first);
|
|
|
|
assert.equal(1, second);
|
2009-10-15 05:56:12 +08:00
|
|
|
});
|