Skip to content

Commit

Permalink
test: ignore stale process cleanup failures on Windows
Browse files Browse the repository at this point in the history
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 7db2974
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/common/child_process.js
Expand Up @@ -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.
}
});
}

Expand Down

0 comments on commit 7db2974

Please sign in to comment.