Skip to content

Close MCP stderr readers on client teardown - #43870

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/1b544e8dba2b5616db6739d075e7232564c92884
Sep 8, 2026
Merged

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

Conversation

@copyberry

@copyberry copyberry Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Close MCP stderr readers on client teardown

Why

A descendant outside an MCP server's process group can keep stderr open after the server exits, leaving the reader task and its file descriptor alive.

What changed

Signal the local stderr reader during explicit shutdown and when the process handle is dropped. Allow up to 250 ms to drain queued diagnostics before closing the reader, even if stderr never reaches EOF.

Testing

Add a Unix regression test covering explicit shutdown and client drop with a descendant that keeps stderr open. Verify that file descriptor counts return to baseline while the descendant remains alive and that queued diagnostics are logged.

## Why

A descendant outside an MCP server's process group can keep stderr open after the server exits, leaving the reader task and its file descriptor alive.

## What changed

Signal the local stderr reader during explicit shutdown and when the process handle is dropped. Allow up to 250 ms to drain queued diagnostics before closing the reader, even if stderr never reaches EOF.

## Testing

Add a Unix regression test covering explicit shutdown and client drop with a descendant that keeps stderr open. Verify that file descriptor counts return to baseline while the descendant remains alive and that queued diagnostics are logged.

GitOrigin-RevId: 1b544e8dba2b5616db6739d075e7232564c92884
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/1b544e8dba2b5616db6739d075e7232564c92884 branch from 5801402 to 44ab726 Compare September 8, 2026 17:43
@copyberry
copyberry Bot merged commit 44ab726 into main Sep 8, 2026
24 of 32 checks passed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/1b544e8dba2b5616db6739d075e7232564c92884 branch September 8, 2026 17:44
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 8, 2026

This branch was previously deployed

1 inactive deployment
issue-triage — 44ab7267 Deployed Sep 8, 2026 by thecosmicskye via Translate non-English issue #11944
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.

2 participants