Skip to content

Commit 9b47c70

Browse files
joyeecheungguangwong
authored andcommitted
test: ignore stale process cleanup failures on Windows
In some tests we try to clean up stale child processes on Windows, but they don't necessarily exist, in that case we should ignore any failures from the WMIC.exe command. PR-URL: nodejs/node#44480 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent c228280 commit 9b47c70

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

test/common/child_process.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ function cleanupStaleProcess(filename) {
1212
}
1313
process.once('beforeExit', () => {
1414
const basename = filename.replace(/.*[/\\]/g, '');
15-
require('child_process')
16-
.execFileSync(`${process.env.SystemRoot}\\System32\\wbem\\WMIC.exe`, [
17-
'process',
18-
'where',
19-
`commandline like '%${basename}%child'`,
20-
'delete',
21-
'/nointeractive',
22-
]);
15+
try {
16+
require('child_process')
17+
.execFileSync(`${process.env.SystemRoot}\\System32\\wbem\\WMIC.exe`, [
18+
'process',
19+
'where',
20+
`commandline like '%${basename}%child'`,
21+
'delete',
22+
'/nointeractive',
23+
]);
24+
} catch {
25+
// Ignore failures, there might not be any stale process to clean up.
26+
}
2327
});
2428
}
2529

0 commit comments

Comments
 (0)