Skip to content

Harden local MCP server process tree cleanup - #37366

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/33d3cc122de8f7ce0ae69a649b12ea0ff64b7c6f
Aug 7, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/33d3cc122de8f7ce0ae69a649b12ea0ff64b7c6f

Conversation

@copyberry

@copyberry copyberry Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Harden local MCP server process tree cleanup

Why

A local stdio MCP server can exit while its descendants remain alive. Cleaning up
only the server process can therefore leak processes after client shutdown.

What changed

  • Contain locally launched MCP servers in non-breakaway Windows job objects and
    terminate the job during shutdown so descendants exit with the server.
  • Preserve compatibility when job creation or assignment is unavailable by
    retrying without containment and terminating an owned process handle instead.
  • Use the process-group member fallback when terminating piped processes on
    macOS.

Testing

  • Cover descendant cleanup and breakaway prevention for both local MCP protocol
    modes on Windows.
  • Cover the Windows nested-job assignment fallback and verify the suspended
    process resumes before handle-based termination.

## Why

A local stdio MCP server can exit while its descendants remain alive. Cleaning up
only the server process can therefore leak processes after client shutdown.

## What changed

- Contain locally launched MCP servers in non-breakaway Windows job objects and
  terminate the job during shutdown so descendants exit with the server.
- Preserve compatibility when job creation or assignment is unavailable by
  retrying without containment and terminating an owned process handle instead.
- Use the process-group member fallback when terminating piped processes on
  macOS.

## Testing

- Cover descendant cleanup and breakaway prevention for both local MCP protocol
  modes on Windows.
- Cover the Windows nested-job assignment fallback and verify the suspended
  process resumes before handle-based termination.

GitOrigin-RevId: 33d3cc122de8f7ce0ae69a649b12ea0ff64b7c6f
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/33d3cc122de8f7ce0ae69a649b12ea0ff64b7c6f branch from 6ccc479 to 9daa491 Compare August 7, 2026 03:36
@copyberry
copyberry Bot merged commit 9daa491 into main Aug 7, 2026
28 of 32 checks passed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/33d3cc122de8f7ce0ae69a649b12ea0ff64b7c6f branch August 7, 2026 03:37
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant