MCPcopy Index your code
hub / github.com/nodejs/node / cleanupStaleProcess

Function cleanupStaleProcess

test/common/child_process.js:11–29  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

9// When CMD is used to launch a process and CMD is killed too quickly, the
10// process can stay behind running in suspended state, never completing.
11function cleanupStaleProcess(filename) {
12 if (!common.isWindows) {
13 return;
14 }
15 process.once('beforeExit', () => {
16 const basename = filename.replace(/.*[/\\]/g, '');
17 try {
18 execFileSync(`${process.env.SystemRoot}\\System32\\wbem\\WMIC.exe`, [
19 'process',
20 'where',
21 `commandline like '%${basename}%child'`,
22 'delete',
23 '/nointeractive',
24 ]);
25 } catch {
26 // Ignore failures, there might not be any stale process to clean up.
27 }
28 });
29}
30
31// This should keep the child process running long enough to expire
32// the timeout.

Calls 2

execFileSyncFunction · 0.85
onceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…