(child: ChildProcess, signal: NodeJS.Signals)
| 126 | // Signal the process GROUP (negative pid); fall back to the direct child |
| 127 | // when the group is already gone. |
| 128 | const signalTree = (child: ChildProcess, signal: NodeJS.Signals) => { |
| 129 | if (child.pid === undefined || child.exitCode !== null) return; |
| 130 | try { |
| 131 | process.kill(-child.pid, signal); |
| 132 | } catch { |
| 133 | child.kill(signal); |
| 134 | } |
| 135 | }; |
| 136 | |
| 137 | const exited = (child: ChildProcess): Promise<void> => |
| 138 | child.exitCode !== null || child.signalCode !== null |