Skip to content

Fix relative MCP server spawning on macOS - #42117

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

Fix relative MCP server spawning on macOS#42117
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/1cbc6b90aed6f67e0a38f551964d80496ebc4471

Conversation

@copyberry

@copyberry copyberry Bot commented Sep 1, 2026

Copy link
Copy Markdown

Fix relative MCP server spawning on macOS

Why

Rust falls back to fork when a macOS command combines a relative executable
path with a working directory, due to a historical posix_spawnp issue. This
can make local MCP server startup less reliable.

What changed

  • Spawn relative macOS MCP executables directly with posix_spawn, preserving
    the configured path, argv[0], working directory, environment, stdio, and
    process group.
  • Keep the existing launcher for PATH lookup and executable text files without
    a shebang.
  • Use one local child wrapper for legacy and 2026-07-28 protocol framing, with
    cancellation-safe waiting and cleanup that kills and reaps dropped children.

Testing

Add macOS regression coverage for relative scripts, argument and descriptor
preservation, launch errors, cancelled waits, and cleanup after runtime shutdown.

## Why

Rust falls back to `fork` when a macOS command combines a relative executable
path with a working directory, due to a historical `posix_spawnp` issue. This
can make local MCP server startup less reliable.

## What changed

- Spawn relative macOS MCP executables directly with `posix_spawn`, preserving
  the configured path, `argv[0]`, working directory, environment, stdio, and
  process group.
- Keep the existing launcher for `PATH` lookup and executable text files without
  a shebang.
- Use one local child wrapper for legacy and 2026-07-28 protocol framing, with
  cancellation-safe waiting and cleanup that kills and reaps dropped children.

## Testing

Add macOS regression coverage for relative scripts, argument and descriptor
preservation, launch errors, cancelled waits, and cleanup after runtime shutdown.

GitOrigin-RevId: 1cbc6b90aed6f67e0a38f551964d80496ebc4471
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/1cbc6b90aed6f67e0a38f551964d80496ebc4471 branch from f8f514d to ea7e071 Compare September 1, 2026 18:54
@copyberry
copyberry Bot merged commit ea7e071 into main Sep 1, 2026
24 of 32 checks passed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/1cbc6b90aed6f67e0a38f551964d80496ebc4471 branch September 1, 2026 18:55
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 1, 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