Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a385277

Browse filesBrowse files
addaleaxcjihrig
authored andcommitted
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: #7854 Fixes: #7981 PR-URL: #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>
1 parent 909254c commit a385277
Copy full SHA for a385277

File tree

Expand file treeCollapse file tree

2 files changed

+10
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-4
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-vm-sigint-existing-handler.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-vm-sigint-existing-handler.js
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,19 @@ if (process.argv[2] === 'child') {
6161
}
6262

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

65+
// Set the `SIGUSR2` handler before spawning the child process to make sure
66+
// the signal is always handled.
6867
process.on('SIGUSR2', common.mustCall(() => {
6968
// First kill() breaks the while(true) loop, second one invokes the real
7069
// signal handlers.
7170
process.kill(child.pid, 'SIGINT');
7271
}, 3));
7372

73+
const child = spawn(process.execPath, [__filename, 'child'], {
74+
stdio: [null, 'inherit', 'inherit']
75+
});
76+
7477
child.on('close', function(code, signal) {
7578
assert.strictEqual(signal, null);
7679
assert.strictEqual(code, 0);
Collapse file

‎test/parallel/test-vm-sigint.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-vm-sigint.js
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ if (process.argv[2] === 'child') {
2525
}
2626

2727
process.env.REPL_TEST_PPID = process.pid;
28+
29+
// Set the `SIGUSR2` handler before spawning the child process to make sure
30+
// the signal is always handled.
2831
process.on('SIGUSR2', common.mustCall(() => {
2932
process.kill(child.pid, 'SIGINT');
3033
}));
3134

32-
const child = spawn(process.execPath, [ __filename, 'child' ], {
35+
const child = spawn(process.execPath, [__filename, 'child'], {
3336
stdio: [null, 'pipe', 'inherit']
3437
});
3538

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.