blob: a058c7ef31007c5a0a6e1d8ff950706cde735658 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
'use strict';
const common = require('../common');
if (common.isWindows) {
common.skip('SIGUSR1 and SIGHUP signals are not supported');
return;
}
console.log('process.pid: ' + process.pid);
process.on('SIGUSR1', common.mustCall(function() {}));
process.on('SIGUSR1', common.mustCall(function() {
setTimeout(function() {
console.log('End.');
process.exit(0);
}, 5);
}));
var i = 0;
setInterval(function() {
console.log('running process...' + ++i);
if (i == 5) {
process.kill(process.pid, 'SIGUSR1');
}
}, 1);
// Test on condition where a watcher for SIGNAL
// has been previously registered, and `process.listeners(SIGNAL).length === 1`
process.on('SIGHUP', function() {});
process.removeAllListeners('SIGHUP');
process.on('SIGHUP', common.mustCall(function() {}));
process.kill(process.pid, 'SIGHUP');
|