(pid)
| 33 | const execFileAsync = promisify(execFile); |
| 34 | |
| 35 | async function childPids(pid) { |
| 36 | try { |
| 37 | const { stdout } = await execFileAsync('pgrep', ['-P', String(pid)]); |
| 38 | return stdout.split('\n').map((line) => line.trim()).filter(Boolean).map(Number); |
| 39 | } catch { |
| 40 | // pgrep endet mit 1, wenn es keine Kinder gibt. Das ist der Normalfall. |
| 41 | return []; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | /** Der Prozessbaum unter (und einschliesslich) pid. */ |
| 46 | async function processTree(pid) { |