| 181 | * Kill the bridge process. |
| 182 | */ |
| 183 | export function stopBridge(): void { |
| 184 | if (bridgeProc) { |
| 185 | try { |
| 186 | const stdin = bridgeProc.stdin |
| 187 | if (stdin) { |
| 188 | const writable = stdin as unknown as Writable |
| 189 | if (typeof writable.end === 'function') { |
| 190 | writable.end() |
| 191 | } |
| 192 | } |
| 193 | bridgeProc.kill() |
| 194 | } catch {} |
| 195 | bridgeProc = null |
| 196 | } |
| 197 | pendingRequests.clear() |
| 198 | outputBuffer = '' |
| 199 | } |
| 200 | |
| 201 | // NOTE: No process exit handlers here — the platform-level win32.ts |
| 202 | // already registers exit/SIGINT/SIGTERM handlers that call cleanupAll(), |