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