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 Sep 13, 2022
1 parent 7850802 commit f691bf5
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/common/child_process.js
Original file line number Diff line number Diff line change
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 f691bf5

Please sign in to comment.