From 9b772250f10da8c5d2ade7c25ccea6ae2601f854 Mon Sep 17 00:00:00 2001 From: João Reis Date: Tue, 16 Jul 2019 19:26:53 +0100 Subject: 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 Reviewed-By: Beth Griggs Reviewed-By: Colin Ihrig --- test/parallel/test-child-process-exec-timeout.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/parallel/test-child-process-exec-timeout.js') diff --git a/test/parallel/test-child-process-exec-timeout.js b/test/parallel/test-child-process-exec-timeout.js index e08aff9085..343050e063 100644 --- a/test/parallel/test-child-process-exec-timeout.js +++ b/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' + ]); + }); +} -- cgit v1.2.3