(pid: string | number)
| 161 | * @returns Array of child process IDs as numbers |
| 162 | */ |
| 163 | export 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 | } |
nothing calls this directly
no test coverage detected