MCPcopy Create free account
hub / github.com/freecodexyz/free-code / getChildPids

Function getChildPids

src/utils/genericProcessUtils.ts:163–184  ·  view source on GitHub ↗
(pid: string | number)

Source from the content-addressed store, hash-verified

161 * @returns Array of child process IDs as numbers
162 */
163export function getChildPids(pid: string | number): number[] {
164 try {
165 const pidStr = String(pid)
166 const command =
167 process.platform === 'win32'
168 ? `powershell.exe -NoProfile -Command "(Get-CimInstance Win32_Process -Filter \\"ParentProcessId=${pidStr}\\").ProcessId"`
169 : `pgrep -P ${pidStr}`
170
171 const result = execSyncWithDefaults_DEPRECATED(command, { timeout: 1000 })
172 if (!result) {
173 return []
174 }
175 return result
176 .trim()
177 .split('\n')
178 .filter(Boolean)
179 .map(p => parseInt(p, 10))
180 .filter(p => !isNaN(p))
181 } catch {
182 return []
183 }
184}

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected