openai/codex · error

failed to reap sandboxed child

Error message

failed to reap sandboxed child: {err}

What it means

The parent sandbox process failed to reap a child via waitpid while waiting for the sandboxed command. This panic fires in the reaping loop when waitpid returns an unexpected error other than EINTR/ECHILD transitions — e.g. ECHILD signaling the child was already reaped elsewhere — meaning the exit status of the sandboxed command can no longer be determined reliably.

Solutions

  1. Inspect the io::Error in the message for the waitpid errno
  2. Check for interfering subprocess supervisors or signal handlers reaping children
  3. Ensure only the sandbox parent waits on the command pid
  4. Report as a bug with the errno if it reproduces
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at codex-rs/linux-sandbox/src/linux_run_main.rs:272 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/a4cab235058d3ea5. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/linux-sandbox/src/linux_run_main.rs:272

        let signal_forwarders = install_bwrap_signal_forwarders(command_pid);
        signal_mask.restore();
        loop {
            let mut status = 0;
            let reaped_pid = unsafe { libc::waitpid(-1, &mut status, 0) };
            if reaped_pid == command_pid {
                let exit_signal_mask = ForwardedSignalMask::block();
                signal_forwarders.restore();
                exit_signal_mask.restore();
                exit_with_wait_status(status);
            }
            if reaped_pid >= 0 {
                continue;
            }

            let err = std::io::Error::last_os_error();
            if err.raw_os_error() != Some(libc::EINTR) {
                panic!("failed to reap sandboxed child: {err}");
            }
        }
    }

    if file_system_sandbox_policy.has_full_disk_write_access() && !allow_network_for_proxy {
        if let Err(e) = apply_permission_profile_to_current_thread(
            &permission_profile,
            &sandbox_policy_cwd,
            /*apply_landlock_fs*/ false,
            allow_network_for_proxy,
            /*proxy_routed_network*/ false,
        ) {
            panic!("error applying Linux sandbox restrictions: {e:?}");
        }
        exec_or_panic(command);
    }

    if !use_legacy_landlock {

View on GitHub (pinned to 339751715c)