2009-10-30 06:34:10 +08:00
|
|
|
process.mixin(require("common.js"));
|
2009-10-06 08:56:33 +08:00
|
|
|
|
2009-10-15 05:56:12 +08:00
|
|
|
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) {
|
2009-10-30 06:34:10 +08:00
|
|
|
process.kill(process.pid, "SIGUSR1");
|
2009-10-15 05:56:12 +08:00
|
|
|
}
|
|
|
|
}, 1);
|
|
|
|
|
|
|
|
|
|
|
|
process.addListener("exit", function () {
|
|
|
|
assertEquals(1, first);
|
|
|
|
assertEquals(1, second);
|
|
|
|
});
|