Skip to content
Permalink
Browse files

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 <rtrott@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information...
joaocgreis authored and BethGriggs committed Jul 16, 2019
1 parent 1a5dc6a commit 92a2f8bbe3748fc265fb859185633584fb9d35c1
Showing with 16 additions and 0 deletions.
  1. +16 −0 test/parallel/test-child-process-exec-timeout.js
@@ -56,3 +56,19 @@ cp.exec(cmd, { timeout: 2 ** 30 }, common.mustCall((err, stdout, stderr) => {
assert.strictEqual(stdout.trim(), 'child stdout');
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'
]);
});
}

0 comments on commit 92a2f8b

Please sign in to comment.
You can’t perform that action at this time.