test: fix flaky test-vm-sigint-existing-handler
Set the `SIGUSR2` handler before spawning the child process to make sure the signal is always handled. Ref: https://github.com/nodejs/node/pull/7854 Fixes: https://github.com/nodejs/node/issues/7981 PR-URL: https://github.com/nodejs/node/pull/7982 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
b635f7b0e7
commit
be73480eec
@ -61,16 +61,19 @@ if (process.argv[2] === 'child') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
process.env.REPL_TEST_PPID = process.pid;
|
process.env.REPL_TEST_PPID = process.pid;
|
||||||
const child = spawn(process.execPath, [ __filename, 'child' ], {
|
|
||||||
stdio: [null, 'inherit', 'inherit']
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// Set the `SIGUSR2` handler before spawning the child process to make sure
|
||||||
|
// the signal is always handled.
|
||||||
process.on('SIGUSR2', common.mustCall(() => {
|
process.on('SIGUSR2', common.mustCall(() => {
|
||||||
// First kill() breaks the while(true) loop, second one invokes the real
|
// First kill() breaks the while(true) loop, second one invokes the real
|
||||||
// signal handlers.
|
// signal handlers.
|
||||||
process.kill(child.pid, 'SIGINT');
|
process.kill(child.pid, 'SIGINT');
|
||||||
}, 3));
|
}, 3));
|
||||||
|
|
||||||
|
const child = spawn(process.execPath, [__filename, 'child'], {
|
||||||
|
stdio: [null, 'inherit', 'inherit']
|
||||||
|
});
|
||||||
|
|
||||||
child.on('close', function(code, signal) {
|
child.on('close', function(code, signal) {
|
||||||
assert.strictEqual(signal, null);
|
assert.strictEqual(signal, null);
|
||||||
assert.strictEqual(code, 0);
|
assert.strictEqual(code, 0);
|
||||||
|
@ -25,11 +25,14 @@ if (process.argv[2] === 'child') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
process.env.REPL_TEST_PPID = process.pid;
|
process.env.REPL_TEST_PPID = process.pid;
|
||||||
|
|
||||||
|
// Set the `SIGUSR2` handler before spawning the child process to make sure
|
||||||
|
// the signal is always handled.
|
||||||
process.on('SIGUSR2', common.mustCall(() => {
|
process.on('SIGUSR2', common.mustCall(() => {
|
||||||
process.kill(child.pid, 'SIGINT');
|
process.kill(child.pid, 'SIGINT');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const child = spawn(process.execPath, [ __filename, 'child' ], {
|
const child = spawn(process.execPath, [__filename, 'child'], {
|
||||||
stdio: [null, 'pipe', 'inherit']
|
stdio: [null, 'pipe', 'inherit']
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user