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: https://github.com/nodejs/build/issues/1829 PR-URL: https://github.com/nodejs/node/pull/28723 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
d0894773a4
commit
9b772250f1
@ -56,3 +56,19 @@ cp.exec(cmd, { timeout: 2 ** 30 }, common.mustCall((err, stdout, stderr) => {
|
|||||||
assert.strictEqual(stdout.trim(), 'child stdout');
|
assert.strictEqual(stdout.trim(), 'child stdout');
|
||||||
assert.strictEqual(stderr.trim(), 'child stderr');
|
assert.strictEqual(stderr.trim(), 'child stderr');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// Workaround for Windows Server 2008R2
|
||||||
|
// 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.
|
||||||
|
if (common.isWindows) {
|
||||||
|
process.once('beforeExit', () => {
|
||||||
|
const basename = __filename.replace(/.*[/\\]/g, '');
|
||||||
|
cp.execFileSync(`${process.env.SystemRoot}\\System32\\wbem\\WMIC.exe`, [
|
||||||
|
'process',
|
||||||
|
'where',
|
||||||
|
`commandline like '%${basename}%child'`,
|
||||||
|
'delete',
|
||||||
|
'/nointeractive'
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user