Skip to content

Use native POSIX spawning for command hooks - #47610

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

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

Conversation

@copyberry

@copyberry copyberry Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Use native POSIX spawning for command hooks

Why

Unix command hooks use a pre_exec callback to detach from the controlling terminal, forcing the launcher to fork. Native spawn attributes can create the detached session without that callback.

What changed

  • Route Unix hooks through codex_utils_pty::Command with ProcessMode::NewSession.
  • Extend the native posix_spawn launcher to detached Linux sessions, retaining compatibility fallbacks for unsupported libc features and executable handling.
  • Preserve the session environment snapshot, hook overrides, and restricted-variable filtering.

Testing

Add regression coverage for launches without parent forks, terminal detachment, environment and argument handling, Linux PATH lookup, and executable compatibility. Cover process-group cleanup on cancellation and timeout, including descendants holding output pipes open, and preservation of background descendants after completed hooks.

## Why

Unix command hooks use a `pre_exec` callback to detach from the controlling terminal, forcing the launcher to fork. Native spawn attributes can create the detached session without that callback.

## What changed

- Route Unix hooks through `codex_utils_pty::Command` with `ProcessMode::NewSession`.
- Extend the native `posix_spawn` launcher to detached Linux sessions, retaining compatibility fallbacks for unsupported libc features and executable handling.
- Preserve the session environment snapshot, hook overrides, and restricted-variable filtering.

## Testing

Add regression coverage for launches without parent forks, terminal detachment, environment and argument handling, Linux `PATH` lookup, and executable compatibility. Cover process-group cleanup on cancellation and timeout, including descendants holding output pipes open, and preservation of background descendants after completed hooks.

GitOrigin-RevId: dbe2cf12d84aa79868cfb55ace40c7d5b5282703
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/dbe2cf12d84aa79868cfb55ace40c7d5b5282703 branch from 5d5ad64 to 7aa6519 Compare September 23, 2026 18:24
@copyberry
copyberry Bot merged commit 7aa6519 into main Sep 23, 2026
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/dbe2cf12d84aa79868cfb55ace40c7d5b5282703 branch September 23, 2026 18:24
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 23, 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