Skip to content

Commit 2afbb3e

Browse files
joaocgreisBethGriggs
authored andcommitted
test,win: cleanup exec-timeout processes
When CMD is used to launch a process and CMD is killed too quickly, the process can stay behind running in suspended state, never completing. This only happens in Windows Server 2008R2. Refs: nodejs/build#1829 PR-URL: #28723 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 9258496 commit 2afbb3e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/parallel/test-child-process-exec-timeout.js

+16
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,19 @@ cp.exec(cmd, { timeout: 2 ** 30 }, common.mustCall((err, stdout, stderr) => {
5656
assert.strictEqual(stdout.trim(), 'child stdout');
5757
assert.strictEqual(stderr.trim(), 'child stderr');
5858
}));
59+
60+
// Workaround for Windows Server 2008R2
61+
// When CMD is used to launch a process and CMD is killed too quickly, the
62+
// process can stay behind running in suspended state, never completing.
63+
if (common.isWindows) {
64+
process.once('beforeExit', () => {
65+
const basename = __filename.replace(/.*[/\\]/g, '');
66+
cp.execFileSync(`${process.env.SystemRoot}\\System32\\wbem\\WMIC.exe`, [
67+
'process',
68+
'where',
69+
`commandline like '%${basename}%child'`,
70+
'delete',
71+
'/nointeractive'
72+
]);
73+
});
74+
}

0 commit comments

Comments
 (0)