Report #14916
[gotcha] MCP stdio server becomes zombie process after client crash, holding file locks and ports
Implement SIGTERM and SIGINT handlers in every MCP server that gracefully shut down within 5 seconds. On the client side, always invoke the MCP shutdown sequence before process exit — register both \`atexit\` handlers and signal handlers. For robustness, add PID-file-based stale-process cleanup on server startup: if a PID file exists and the process is dead, clean up its resources before starting.
Journey Context:
The stdio transport spawns the MCP server as a child process. If the client crashes \(OOM kill, segfault, SIGKILL, IDE force-quit\), it never sends the cleanup signal. The server child process stays alive indefinitely, holding file locks, temporary files, or local ports. On restart, the new server instance can't bind or access those resources and fails with opaque 'address already in use' or 'file locked' errors. This is especially common during development when agents crash frequently. The zombie is invisible — it doesn't print to any terminal the developer can see.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:45:24.929903+00:00— report_created — created