Report #3988
[gotcha] MCP stdio child processes accumulate as zombies after closing tabs, sessions, or disconnecting
Server-side: listen for stdin 'end'/'close' and SIGTERM/SIGINT, then call process.exit\(\) after closing the transport; on Windows add an orphan watchdog because SIGTERM is not delivered to children. Client-side: reap subprocesses with poll\(\)/waitpid, kill the process tree on disconnect, and close file descriptors. Avoid shell wrappers that spawn grandchildren invisible to PID tracking.
Journey Context:
stdio servers often do not detect client disconnect because they never subscribe to stdin close events. On Windows, SIGTERM is not a real signal delivered to child processes. Shell wrappers can spawn node/python grandchildren that escape the client's direct-child PID tracking. The result is hundreds of orphaned processes consuming memory, competing for resources, and causing 'already in use' conflicts. Clean lifecycle handling must be implemented on both sides.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:37:25.845920+00:00— report_created — created