Skip to content

fix(linux-sandbox): preserve detached children#14891

Open
viyatb-oai wants to merge 15 commits intomainfrom
codex/viyatb/fix-linux-sandbox-detached-children
Open

fix(linux-sandbox): preserve detached children#14891
viyatb-oai wants to merge 15 commits intomainfrom
codex/viyatb/fix-linux-sandbox-detached-children

Conversation

@viyatb-oai
Copy link
Copy Markdown
Collaborator

@viyatb-oai viyatb-oai commented Mar 17, 2026

Summary

  • stop passing bubblewrap --die-with-parent for Linux sandbox tool invocations so detached descendants can survive after the initial one-shot command exits
  • keep --unshare-user and --unshare-pid so the sandboxed process tree still runs in isolated user and PID namespaces
  • add Linux regression coverage for a detached child that keeps writing after the parent exits

Context

This addresses regression B from #14875. Regression A was split into a separate PR: #14890.

The important detail here is that the regression is not caused by the PID namespace by itself. The failing behavior is that an intentionally detached child still gets torn down when bubblewrap is asked to tie sandbox lifetime to the original parent process. This PR keeps the namespace isolation and scopes the behavior change to removing --die-with-parent.

That means the semantic change is narrow but real: detached descendants can now outlive the initial one-shot helper process when the caller intentionally launches them that way. That is what restores the detached-child use case behind the WSL / Playwright bridge regression, but it also means intentionally detached sandbox descendants may remain alive if the original helper exits unexpectedly.

Validation

  • just fmt
  • cargo test -p codex-linux-sandbox
  • cargo clippy -p codex-linux-sandbox --tests -- -D warnings
  • cargo clean

Note: this checkout is macOS, so the Linux-only runtime tests compile but do not execute locally here.

@viyatb-oai viyatb-oai force-pushed the codex/viyatb/fix-linux-sandbox-detached-children branch from 7dcd5f3 to e2b7bde Compare March 17, 2026 07:08
…x-sandbox-detached-children

# Conflicts:
#	codex-rs/linux-sandbox/tests/suite/landlock.rs
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/fix-linux-sandbox-detached-children branch from e4595d5 to 5ac5801 Compare March 17, 2026 07:45
@viyatb-oai viyatb-oai requested a review from jif-oai March 17, 2026 07:56
…x-sandbox-detached-children

# Conflicts:
#	codex-rs/core/src/exec.rs
#	codex-rs/core/src/landlock.rs
#	codex-rs/core/src/sandboxing/mod.rs
#	codex-rs/core/src/tools/runtimes/shell/unix_escalation.rs
#	codex-rs/sandboxing/src/policy_transforms_tests.rs
@viyatb-oai viyatb-oai requested a review from bolinfest March 25, 2026 14:25
…x-sandbox-detached-children

# Conflicts:
#	codex-rs/core/src/landlock.rs
#	codex-rs/linux-sandbox/src/linux_run_main.rs
#	codex-rs/sandboxing/src/lib.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants