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