mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.0 KiB
50 lines
1.0 KiB
13 years ago
|
// SIGUSR1 and SIGHUP are not supported on Windows
|
||
|
if (process.platform === 'win32') {
|
||
|
process.exit(0);
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
var common = require('../common');
|
||
|
var assert = require('assert');
|
||
15 years ago
|
|
||
14 years ago
|
console.log('process.pid: ' + process.pid);
|
||
15 years ago
|
|
||
|
var first = 0,
|
||
|
second = 0;
|
||
|
|
||
14 years ago
|
var sighup = false;
|
||
|
|
||
13 years ago
|
process.on('SIGUSR1', function() {
|
||
14 years ago
|
console.log('Interrupted by SIGUSR1');
|
||
15 years ago
|
first += 1;
|
||
|
});
|
||
|
|
||
13 years ago
|
process.on('SIGUSR1', function() {
|
||
15 years ago
|
second += 1;
|
||
14 years ago
|
setTimeout(function() {
|
||
|
console.log('End.');
|
||
15 years ago
|
process.exit(0);
|
||
|
}, 5);
|
||
|
});
|
||
|
|
||
14 years ago
|
var i = 0;
|
||
14 years ago
|
setInterval(function() {
|
||
|
console.log('running process...' + ++i);
|
||
15 years ago
|
|
||
|
if (i == 5) {
|
||
14 years ago
|
process.kill(process.pid, 'SIGUSR1');
|
||
15 years ago
|
}
|
||
|
}, 1);
|
||
|
|
||
13 years ago
|
// Test on condition where a watcher for SIGNAL
|
||
14 years ago
|
// has been previously registered, and `process.listeners(SIGNAL).length === 1`
|
||
13 years ago
|
process.on('SIGHUP', function() {});
|
||
14 years ago
|
process.removeAllListeners('SIGHUP');
|
||
13 years ago
|
process.on('SIGHUP', function() { sighup = true });
|
||
14 years ago
|
process.kill(process.pid, 'SIGHUP');
|
||
15 years ago
|
|
||
13 years ago
|
process.on('exit', function() {
|
||
15 years ago
|
assert.equal(1, first);
|
||
|
assert.equal(1, second);
|
||
14 years ago
|
assert.equal(true, sighup);
|
||
15 years ago
|
});
|