Files
node/test/parallel/test-signal-handler.js
Vse Mozhet Byt 1633f8b243 test: simplify test skipping
* Make common.skip() exit.

  Also add common.printSkipMessage() for partial skips.

* Don't make needless things before skip

Backport-PR-URL: https://github.com/nodejs/node/pull/14838
PR-URL: https://github.com/nodejs/node/pull/14021
Fixes: https://github.com/nodejs/node/issues/14016
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-09-05 12:49:51 -04:00

34 lines
804 B
JavaScript

'use strict';
const common = require('../common');
if (common.isWindows)
common.skip('SIGUSR1 and SIGHUP signals are not supported');
console.log(`process.pid: ${process.pid}`);
process.on('SIGUSR1', common.mustCall());
process.on('SIGUSR1', common.mustCall(function() {
setTimeout(function() {
console.log('End.');
process.exit(0);
}, 5);
}));
let 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', common.mustNotCall());
process.removeAllListeners('SIGHUP');
process.on('SIGHUP', common.mustCall());
process.kill(process.pid, 'SIGHUP');