--full-auto and --sandbox workspace-write flags cause indefinite hang with orphaned child processes
What version of Codex is running?
codex-cli 0.66.0
What subscription do you have?
PRO
Which model were you using?
gpt-5.1-codex-max
What platform is your computer?
Linux 6.8.0-87-generic x86_64
What issue are you seeing?
When using --full-auto or --sandbox workspace-write flags with codex exec, commands hang indefinitely even for simple operations that complete in milliseconds without these flags.
Test results:
| Command | Result | Time |
|---------|--------|------|
| codex exec "echo test" | ✅ Works | ~2s |
| codex exec --json "echo test" | ✅ Works | ~2s |
| codex exec --full-auto "echo test" | ❌ HANGS | >2min |
| codex exec --sandbox workspace-write "echo test" | ❌ HANGS | >2min |
Symptoms:
- Command output shows successful completion in JSONL log
- Codex never returns control to caller
- Child processes remain orphaned in
S(sleeping) state exit_code: null, status: "in_progress"persists indefinitely
Note: This is separate from issue #7846 (process substitution). This bug occurs with the --full-auto/--sandbox flags themselves, even with simple commands like echo.
What steps can reproduce the bug?
Minimal reproduction:
```bash
# Step 1: This WORKS (no sandbox flags)
timeout 30s codex exec --dangerously-bypass-approvals-and-sandbox \
"Run: echo 'hello world'"
# Result: Completes in ~2-5 seconds
# Step 2: This HANGS (with --full-auto)
timeout 30s codex exec --dangerously-bypass-approvals-and-sandbox \
--full-auto "Run: echo 'hello world'"
# Result: Times out after 30s
# Step 3: This also HANGS (with --sandbox workspace-write)
timeout 30s codex exec --dangerously-bypass-approvals-and-sandbox \
--sandbox workspace-write "Run: echo 'hello world'"
# Result: Times out after 30s
# Step 4: Check for orphaned processes after timeout
pgrep -af 'codex|echo' | grep -v pgrep
```
### Full reproduction script:
```bash
#!/usr/bin/env bash
set -euo pipefail
echo "=== Test 1: Without --full-auto ==="
time timeout 20s codex exec --dangerously-bypass-approvals-and-sandbox \
"Run: echo test" 2>&1 | tail -3
echo "=== Test 2: With --full-auto (will hang) ==="
time timeout 20s codex exec --dangerously-bypass-approvals-and-sandbox \
--full-auto "Run: echo test" 2>&1 | tail -3
echo "Exit code: $?"
```
What is the expected behavior?
- Commands with
--full-autoshould complete in similar time as without the flag (~2-5s for simple commands) - All child processes should be terminated when Codex exits
- No orphaned processes should remain after command completion
exit_codeshould be set to actual return value (0 for success)
Additional information
Root cause analysis:
The issue appears to be in process group management when sandbox mode is active:
- Missing
setpgid(0, 0)- Child processes not placed in own process group - Signal propagation - Signals sent only to direct child PID, not entire group
- Grandchild orphaning - Sandbox intermediate processes create orphans
- Pipe deadlock - Codex waits for EOF on pipes kept open by orphans
### Related issues:
- #7846 - Process substitution hang (different trigger, same root cause)
- #4726 - Missing child.wait() (closed)
- #3836 - Async process management
### Workaround:
Remove --full-auto flag. Use --json alone if JSON output needed.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗