Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0ebc683

Browse files
joyeecheungguangwong
authored andcommittedJan 3, 2023
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: nodejs/node#44480 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 62f94ec commit 0ebc683

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed
 

‎test/common/child_process.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ function cleanupStaleProcess(filename) {
1212
}
1313
process.once('beforeExit', () => {
1414
const basename = filename.replace(/.*[/\\]/g, '');
15-
require('child_process')
16-
.execFileSync(`${process.env.SystemRoot}\\System32\\wbem\\WMIC.exe`, [
17-
'process',
18-
'where',
19-
`commandline like '%${basename}%child'`,
20-
'delete',
21-
'/nointeractive',
22-
]);
15+
try {
16+
require('child_process')
17+
.execFileSync(`${process.env.SystemRoot}\\System32\\wbem\\WMIC.exe`, [
18+
'process',
19+
'where',
20+
`commandline like '%${basename}%child'`,
21+
'delete',
22+
'/nointeractive',
23+
]);
24+
} catch {
25+
// Ignore failures, there might not be any stale process to clean up.
26+
}
2327
});
2428
}
2529

0 commit comments

Comments
 (0)
Please sign in to comment.