0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00
nodejs/test/async-hooks/test-graph.signal.js
blade254353074 0aae941dbe test: use template literals as appropriate
Replace string concatenation with template string literals in
test-graph.signal.js.

PR-URL: https://github.com/nodejs/node/pull/14289
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2017-07-17 05:35:57 -07:00

60 lines
1.8 KiB
JavaScript

'use strict';
const common = require('../common');
if (common.isWindows) {
common.skip('no signals on Windows');
return;
}
const initHooks = require('./init-hooks');
const verifyGraph = require('./verify-graph');
const exec = require('child_process').exec;
const hooks = initHooks();
hooks.enable();
process.on('SIGUSR2', common.mustCall(onsigusr2, 2));
let count = 0;
exec(`kill -USR2 ${process.pid}`);
function onsigusr2() {
count++;
if (count === 1) {
// trigger same signal handler again
exec(`kill -USR2 ${process.pid}`);
} else {
// install another signal handler
process.removeAllListeners('SIGUSR2');
process.on('SIGUSR2', common.mustCall(onsigusr2Again));
exec(`kill -USR2 ${process.pid}`);
}
}
function onsigusr2Again() {}
process.on('exit', onexit);
function onexit() {
hooks.disable();
verifyGraph(
hooks,
[ { type: 'SIGNALWRAP', id: 'signal:1', triggerAsyncId: null },
{ type: 'PROCESSWRAP', id: 'process:1', triggerAsyncId: null },
{ type: 'PIPEWRAP', id: 'pipe:1', triggerAsyncId: null },
{ type: 'PIPEWRAP', id: 'pipe:2', triggerAsyncId: null },
{ type: 'PIPEWRAP', id: 'pipe:3', triggerAsyncId: null },
{ type: 'PROCESSWRAP', id: 'process:2', triggerAsyncId: 'signal:1' },
{ type: 'PIPEWRAP', id: 'pipe:4', triggerAsyncId: 'signal:1' },
{ type: 'PIPEWRAP', id: 'pipe:5', triggerAsyncId: 'signal:1' },
{ type: 'PIPEWRAP', id: 'pipe:6', triggerAsyncId: 'signal:1' },
{ type: 'SIGNALWRAP', id: 'signal:2', triggerAsyncId: 'signal:1' },
{ type: 'PROCESSWRAP', id: 'process:3', triggerAsyncId: 'signal:1' },
{ type: 'PIPEWRAP', id: 'pipe:7', triggerAsyncId: 'signal:1' },
{ type: 'PIPEWRAP', id: 'pipe:8', triggerAsyncId: 'signal:1' },
{ type: 'PIPEWRAP', id: 'pipe:9', triggerAsyncId: 'signal:1' } ]
);
}