mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
## Why Linux descriptor cleanup used allocating directory enumeration after `fork`. The child needs allocation-free cleanup while preserving Rust's spawn-error channel until `exec` succeeds. ## What changed - Mark unrelated descriptors close-on-exec with `close_range(CLOSE_RANGE_CLOEXEC)`, leaving stdio and explicitly preserved descriptors' flags untouched. - Fall back to stack-backed `getdents64` enumeration of the child's descriptor table when `close_range` fails. - Document best-effort cleanup: failures allow launch to proceed and may leave unrelated descriptors inherited. ## Testing Add Linux tests for descriptor inheritance, unsorted and duplicate allowlists, unchanged parent descriptors, fallback cleanup above a lowered descriptor limit, preserved exec-error reporting, and successful launch when both cleanup paths fail. Retain MCP coverage for descriptor exclusion in servers and descendants. GitOrigin-RevId: 13abb95f82557324c7b40feb36bd6f806d60674e