Skip to content

Commit e0e9a37

Browse files
committed
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.
1 parent 82cfb50 commit e0e9a37

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/common/child_process.js

Lines changed: 5 additions & 1 deletion
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')
15+
try {
16+
require('child_process')
1617
.execFileSync(`${process.env.SystemRoot}\\System32\\wbem\\WMIC.exe`, [
1718
'process',
1819
'where',
1920
`commandline like '%${basename}%child'`,
2021
'delete',
2122
'/nointeractive',
2223
]);
24+
} catch {
25+
// Ignore failures, there might not be any stale process to clean up.
26+
}
2327
});
2428
}
2529

0 commit comments

Comments
 (0)