| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 74a5e91 commit efdeb69
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,11 +5,17 @@ const assert = require('assert'); | |||
| 5 | 5 | const path = require('path'); | |
| 6 | 6 | const spawn = require('child_process').spawn; | |
| 7 | 7 | ||
| 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 | + | ||
| 8 | 14 | const children = []; | |
| 9 | 15 | for (let i = 0; i < 4; i += 1) { | |
| 10 | 16 | const port = common.PORT + i; | |
| 11 | 17 | 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' }); | ||
| 13 | 19 | child.test = { port: port, stdout: '' }; | |
| 14 | 20 | child.stdout.setEncoding('utf8'); | |
| 15 | 21 | child.stdout.on('data', function(s) { child.test.stdout += s; update(); }); | |
@@ -28,7 +34,18 @@ function update() { | |||
| 28 | 34 | ||
| 29 | 35 | if (ready === children.length) | |
| 30 | 36 | 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 | + } | ||
| 32 | 49 | } | |
| 33 | 50 | ||
| 34 | 51 | process.on('exit', function() { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments