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)
| 626 | * {@link startPpidWatchdog} but with no socket to close (the caller's shutdown |
| 627 | * handles teardown). */ |
| 628 | function startPpidWatchdogNoSocket(onDeath: () => void): void { |
| 629 | const pollMs = parsePollMs(process.env.CODEGRAPH_PPID_POLL_MS); |
| 630 | if (pollMs <= 0) return; |
| 631 | // Baseline from the CLI entry's earliest capture, not process.ppid here — |
| 632 | // a launcher killed during our first ~100ms would otherwise leave the |
| 633 | // baseline at 1 and blind the divergence check forever (#1185). |
| 634 | const originalPpid = EARLY_PPID; |
| 635 | const hostPpid = parseHostPpid(process.env[HOST_PPID_ENV]); |
| 636 | const timer = setInterval(() => { |
| 637 | const reason = supervisionLostReason({ |
| 638 | originalPpid, |
| 639 | currentPpid: process.ppid, |
| 640 | hostPpid, |
| 641 | isAlive: isProcessAliveLocal, |
| 642 | }); |
| 643 | if (reason) { |
| 644 | process.stderr.write(`[CodeGraph MCP] Parent process exited (${reason}); shutting down.\n`); |
| 645 | onDeath(); |
| 646 | } |
| 647 | }, pollMs); |
| 648 | timer.unref?.(); |
| 649 | } |
| 650 | |
| 651 | /** |
| 652 | * Read one CRLF/LF-terminated JSON line from the socket, parse it as the |
no test coverage detected