Skip to content
Permalink
Browse files
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 <luigipinca@gmail.com>
  • Loading branch information
joyeecheung authored and RafaelGSS committed Sep 26, 2022
1 parent 4ad1b0a commit 7db2974692af494b2c6c02f7f58de931778b1f76
Showing 1 changed file with 12 additions and 8 deletions.
@@ -12,14 +12,18 @@ function cleanupStaleProcess(filename) {
}
process.once('beforeExit', () => {
const basename = filename.replace(/.*[/\\]/g, '');
require('child_process')
.execFileSync(`${process.env.SystemRoot}\\System32\\wbem\\WMIC.exe`, [
'process',
'where',
`commandline like '%${basename}%child'`,
'delete',
'/nointeractive',
]);
try {
require('child_process')
.execFileSync(`${process.env.SystemRoot}\\System32\\wbem\\WMIC.exe`, [
'process',
'where',
`commandline like '%${basename}%child'`,
'delete',
'/nointeractive',
]);
} catch {
// Ignore failures, there might not be any stale process to clean up.
}
});
}

0 comments on commit 7db2974

Please sign in to comment.