Skip to content

Commit 353cd84

Browse files
joyeecheungRafaelGSS
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: #44480 Reviewed-By: Luigi Pinca <[email protected]>
1 parent 5eb48b6 commit 353cd84

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

test/common/child_process.js

+12-8
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)