MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / killOrphansByName

Function killOrphansByName

packages/cli/src/utils/orphanCleanup.ts:88–113  ·  view source on GitHub ↗
(processName: string)

Source from the content-addressed store, hash-verified

86}
87
88function killOrphansByName(processName: string): number {
89 const uid = getUid();
90 const userFlag = uid !== null ? `-u ${uid} ` : "";
91 let pids: number[];
92 try {
93 const raw = execSync(`pgrep ${userFlag}-f ${processName}`, {
94 encoding: "utf-8",
95 timeout: 3000,
96 }).trim();
97 if (!raw) return 0;
98 pids = raw
99 .split("\n")
100 .map((s) => parseInt(s, 10))
101 .filter((n) => !isNaN(n) && n > 0);
102 } catch {
103 return 0;
104 }
105
106 let killed = 0;
107 for (const pid of pids) {
108 if (!isOrphan(pid)) continue;
109 killProcessTree(pid);
110 killed++;
111 }
112 return killed;
113}
114
115let _cachedUid: string | null | undefined;
116

Callers 1

killOrphanedProcessesFunction · 0.85

Calls 3

getUidFunction · 0.85
isOrphanFunction · 0.85
killProcessTreeFunction · 0.85

Tested by

no test coverage detected