mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 07:27:22 +01:00
334d56d2be
Also process.pid and node.kill().
35 lines
583 B
JavaScript
35 lines
583 B
JavaScript
node.mixin(require("common.js"));
|
|
|
|
puts("process.pid: " + process.pid);
|
|
|
|
var first = 0,
|
|
second = 0;
|
|
|
|
process.addListener('SIGUSR1', function () {
|
|
puts("Interrupted by SIGUSR1");
|
|
first += 1;
|
|
});
|
|
|
|
process.addListener('SIGUSR1', function () {
|
|
second += 1;
|
|
setTimeout(function () {
|
|
puts("End.");
|
|
process.exit(0);
|
|
}, 5);
|
|
});
|
|
|
|
i = 0;
|
|
setInterval(function () {
|
|
puts("running process..." + ++i);
|
|
|
|
if (i == 5) {
|
|
node.kill(process.pid, node.SIGUSR1);
|
|
}
|
|
}, 1);
|
|
|
|
|
|
process.addListener("exit", function () {
|
|
assertEquals(1, first);
|
|
assertEquals(1, second);
|
|
});
|