Skip to content

MCP stdio server can remain running after parent process exits #406

Closed

Description

@nvt-pankajsharma

Summary

When the MCP stdio server is launched by an agent/runtime and the parent process exits unexpectedly, the child codebase-memory-mcp process can keep running. That orphaned process may continue holding memory and contribute to out-of-memory conditions over time.

Expected behavior

The stdio MCP server should terminate when its launching parent process dies, matching the lifecycle of the agent/runtime that owns the stdio session.

Actual behavior

If the parent process dies without cleanly closing stdio, the server can remain alive as an orphaned process.

Proposed fix

Add a POSIX parent-process watchdog for the stdio MCP server and cover it with a regression script that kills the parent wrapper and verifies the child exits. Windows should remain explicitly skipped until a Windows-specific parent-death mechanism is added.

Validation plan

  • scripts/test.sh
  • scripts/lint.sh --ci
  • scripts/build.sh CC=cc CXX=c++
  • make -f Makefile.cbm security

Activity

  1. added
    bugSomething isn't working
    editor/integrationEditor compatibility and CLI integration
    on Jun 6, 2026
  2. added 4 commits that reference this issue on Jun 6, 2026
  3. DeusData commented on Jun 7, 2026

    @DeusData
    Owner

    Fixed on main. The stdio server now exits when its launching parent dies, via a POSIX getppid() watchdog (distilled from @nvt-pankajsharma's PR #407 in de1d58a), plus a smoke-test guard (e83bd73, Phase 16) that verifies a shut-down instance leaves no orphan process.

    Thanks for the report and the clear $PPID analysis. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingeditor/integrationEditor compatibility and CLI integration

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions