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 efdeb69

Browse filesBrowse files
bnoordhuisMyles Borins
authored andcommitted
test: work around debugger not killing inferior
On UNIX platforms, the debugger doesn't reliably kill the inferior when killed by a signal. Work around that by spawning the debugger in its own process group and killing the process group instead of just the debugger process. This is a hack to get the continuous integration back to green, it doesn't address the underlying issue, which is that the debugger shouldn't leave stray processes behind. Fixes: #7034 PR-URL: #7037 Refs: #3470 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 74a5e91 commit efdeb69
Copy full SHA for efdeb69

File tree

Expand file treeCollapse file tree

1 file changed

+19
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-2
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-debug-port-numbers.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-debug-port-numbers.js
+19-2Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ const assert = require('assert');
55
const path = require('path');
66
const spawn = require('child_process').spawn;
77

8+
// FIXME(bnoordhuis) On UNIX platforms, the debugger doesn't reliably kill
9+
// the inferior when killed by a signal. Work around that by spawning
10+
// the debugger in its own process group and killing the process group
11+
// instead of just the debugger process.
12+
const detached = !common.isWindows;
13+
814
const children = [];
915
for (let i = 0; i < 4; i += 1) {
1016
const port = common.PORT + i;
1117
const args = [`--debug-port=${port}`, '--interactive', 'debug', __filename];
12-
const child = spawn(process.execPath, args, { stdio: 'pipe' });
18+
const child = spawn(process.execPath, args, { detached, stdio: 'pipe' });
1319
child.test = { port: port, stdout: '' };
1420
child.stdout.setEncoding('utf8');
1521
child.stdout.on('data', function(s) { child.test.stdout += s; update(); });
@@ -28,7 +34,18 @@ function update() {
2834

2935
if (ready === children.length)
3036
for (const child of children)
31-
child.kill();
37+
kill(child);
38+
}
39+
40+
function kill(child) {
41+
if (!detached)
42+
return child.kill();
43+
44+
try {
45+
process.kill(-child.pid); // Kill process group.
46+
} catch (e) {
47+
assert.strictEqual(e.code, 'ESRCH'); // Already gone.
48+
}
3249
}
3350

3451
process.on('exit', function() {

0 commit comments

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