Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix flaky test-vm-sigint-existing-handler #7982

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 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,19 @@ if (process.argv[2] === 'child') {
}

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(() => {
// 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' ], {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before landing, would you mind removing the spaces inside of the braces?

stdio: [null, 'inherit', 'inherit']
});

child.on('close', function(code, signal) {
assert.strictEqual(signal, null);
assert.strictEqual(code, 0);
Expand Down
3 changes: 3 additions & 0 deletions test/parallel/test-vm-sigint.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ if (process.argv[2] === 'child') {
}

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.kill(child.pid, 'SIGINT');
}));
Expand Down