Skip to content

Commit

Permalink
test: fix flaky test-vm-sigint-existing-handler
Browse files Browse the repository at this point in the history
Set the `SIGUSR2` handler before spawning the child process to make sure
the signal is always handled.

Ref: nodejs#7854
Fixes: nodejs#7981
  • Loading branch information
addaleax committed Aug 4, 2016
1 parent 1a9e247 commit f0bf2c2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/parallel/test-vm-sigint-existing-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,17 @@ if (process.argv[2] === 'child') {
}

process.env.REPL_TEST_PPID = process.pid;
const child = spawn(process.execPath, [ __filename, 'child' ], {
stdio: [null, 'inherit', 'inherit']
});

process.on('SIGUSR2', common.mustCall(() => {
// First kill() breaks the while(true) loop, second one invokes the real
// signal handlers.
process.kill(child.pid, 'SIGINT');
}, 3));

const child = spawn(process.execPath, [ __filename, 'child' ], {
stdio: [null, 'inherit', 'inherit']
});

child.on('close', function(code, signal) {
assert.strictEqual(signal, null);
assert.strictEqual(code, 0);
Expand Down

0 comments on commit f0bf2c2

Please sign in to comment.