fix(mcp): close browser when host dies without a signal#41089
Conversation
The MCP exit watchdog only reacted to stdin 'close', SIGINT and SIGTERM. When the host process dies without delivering a signal (SIGKILL, OOM kill, IDE hard-reload), the server is re-parented and none of those fire, leaking the browser process tree. Poll the parent pid and shut down once orphaned. Fixes: microsoft#41013
This applies to any termination, including SIGKILL — the kernel performs the same fd cleanup; user code doesn't get a say.
So: host dies → kernel closes host's fds → if host was the sole holder of the pipe's write end, refcount hits zero → child's next read() on stdin returns 0. Guaranteed by the kernel, not by the host's cooperation. |
Test results for "MCP"431 failed 6807 passed, 1108 skipped Merge workflow run. |
Test results for "tests 1"3 flaky39480 passed, 775 skipped Merge workflow run. |
Summary
close,SIGINTandSIGTERM. When the host dies without delivering a signal (SIGKILL, OOM kill, IDE hard-reload), the server is re-parented and none of those fire, leaking the browser process tree.isAlivetest helper intotests/config/utils.ts.Fixes #41013