(pid: number)
| 164 | } |
| 165 | |
| 166 | function listLinuxChildPids(pid: number): number[] { |
| 167 | const procChildren = readLinuxChildrenFromProc(pid); |
| 168 | if (procChildren) return procChildren; |
| 169 | |
| 170 | try { |
| 171 | const output = execSync(`ps -o pid= --ppid ${pid}`, { encoding: "utf-8" }); |
| 172 | return String(output) |
| 173 | .split(/\s+/) |
| 174 | .map((item) => Number(item.trim())) |
| 175 | .filter((item) => Number.isInteger(item) && item > 0); |
| 176 | } catch (error) { |
| 177 | return []; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | function readLinuxChildrenFromProc(pid: number): number[] | null { |
| 182 | try { |
no test coverage detected