PPID watchdog for the local-handshake proxy — same #277 logic as * startPpidWatchdog but with no socket to close (the caller's shutdown * handles teardown).
(onDeath: () => void)
| 415 | * {@link startPpidWatchdog} but with no socket to close (the caller's shutdown |
| 416 | * handles teardown). */ |
| 417 | function startPpidWatchdogNoSocket(onDeath: () => void): void { |
| 418 | const pollMs = parsePollMs(process.env.CODEGRAPH_PPID_POLL_MS); |
| 419 | if (pollMs <= 0) return; |
| 420 | // Baseline from the CLI entry's earliest capture, not process.ppid here — |
| 421 | // a launcher killed during our first ~100ms would otherwise leave the |
| 422 | // baseline at 1 and blind the divergence check forever (#1185). |
| 423 | const originalPpid = EARLY_PPID; |
| 424 | const hostPpid = parseHostPpid(process.env[HOST_PPID_ENV]); |
| 425 | const timer = setInterval(() => { |
| 426 | const reason = supervisionLostReason({ |
| 427 | originalPpid, |
| 428 | currentPpid: process.ppid, |
| 429 | hostPpid, |
| 430 | isAlive: isProcessAliveLocal, |
| 431 | }); |
| 432 | if (reason) { |
| 433 | process.stderr.write(`[CodeGraph MCP] Parent process exited (${reason}); shutting down.\n`); |
| 434 | onDeath(); |
| 435 | } |
| 436 | }, pollMs); |
| 437 | timer.unref?.(); |
| 438 | } |
| 439 | |
| 440 | /** |
| 441 | * Read one CRLF/LF-terminated JSON line from the socket, parse it as the |
no test coverage detected