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 e0e9a37
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion 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')
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 e0e9a37

Please sign in to comment.