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