| 78 | * listening on its port. |
| 79 | */ |
| 80 | export function signalProcessTree(proc, signal) { |
| 81 | if (!isProcessRunning(proc)) { |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | try { |
| 86 | if (process.platform === "win32" && proc.pid) { |
| 87 | killWindowsProcessTree(proc, signal); |
| 88 | } else if (!proc.pid) { |
| 89 | proc.kill(signal); |
| 90 | } else { |
| 91 | process.kill(-proc.pid, signal); |
| 92 | } |
| 93 | return true; |
| 94 | } catch (err) { |
| 95 | if (err?.code === "ESRCH") { |
| 96 | return false; |
| 97 | } |
| 98 | throw err; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Windows has no POSIX process groups: ChildProcess#kill reaches only the |