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.
  • Loading branch information
joyeecheung committed Sep 1, 2022
1 parent 82cfb50 commit 7edb817
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 7edb817

Please sign in to comment.