Skip to content

fix: make prctl(PR_SET_PDEATHSIG) non-fatal for Lambda compatibility - #1

Merged
tyrchen merged 1 commit into
mainfrom
fix/lambda-prctl-compat
Feb 28, 2026
Merged

tyrchen merged 1 commit into
mainfrom
fix/lambda-prctl-compat

Conversation

@tyrchen

@tyrchen tyrchen commented Feb 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Make prctl(PR_SET_PDEATHSIG) gracefully handle EPERM instead of failing, enabling Codex CLI to run on AWS Lambda
  • Add GitHub Actions workflow (lambda-build.yml) to produce aarch64-unknown-linux-musl binary for Lambda Layers

Problem

AWS Lambda runs inside a Firecracker microVM with a guest-side seccomp profile that blocks prctl(PR_SET_PDEATHSIG). This causes every subprocess spawn from Codex to fail with "Operation not permitted (os error 1)" — even when --dangerously-bypass-approvals-and-sandbox is used, because the prctl call is in the core process spawner (spawn.rs), not in the sandbox layer.

This was reported in openai#4725 and closed as NOT_PLANNED.

Fix

The parent-death signal is a best-effort cleanup mechanism. When prctl fails with EPERM, we now return Ok(()) instead of propagating the error. The existing kill_on_drop(true) on tokio::process::Command provides an alternative cleanup path.

Patched call sites:

  • codex-rs/utils/pty/src/process_group.rs — core spawn path used by all tool calls
  • codex-rs/linux-sandbox/src/proxy_routing.rs — network proxy subprocess
  • codex-rs/utils/sleep-inhibitor/src/linux_inhibitor.rs — sleep inhibitor subprocess

Test plan

  • Verify the lambda-build GitHub Actions workflow produces a working binary
  • Deploy the patched binary to AWS Lambda Layer and confirm Codex can spawn subprocesses (ls, cat, find, rg)
  • Verify no regression on standard Linux (prctl succeeds normally)
  • Verify other prctl errors (non-EPERM) still propagate correctly

🤖 Generated with Claude Code

AWS Lambda's Firecracker seccomp profile blocks prctl(PR_SET_PDEATHSIG),
causing every subprocess spawn to fail with "Operation not permitted"
(EPERM). This happens even with --dangerously-bypass-approvals-and-sandbox
because the prctl call is in the process spawner (spawn.rs, pipe.rs,
sleep-inhibitor), not in the sandbox layer.

The parent-death signal is a best-effort cleanup mechanism — when it
fails with EPERM, we gracefully continue instead of propagating the
error. The existing kill_on_drop(true) on tokio::process::Command
provides an alternative cleanup path.

Patched call sites:
- codex-rs/utils/pty/src/process_group.rs (core spawn + pipe paths)
- codex-rs/linux-sandbox/src/proxy_routing.rs (network proxy)
- codex-rs/utils/sleep-inhibitor/src/linux_inhibitor.rs

Also adds a GitHub Actions workflow (lambda-build.yml) to produce a
statically linked aarch64-unknown-linux-musl binary for Lambda Layers.

Ref: openai#4725

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@tyrchen
tyrchen merged commit 649f800 into main Feb 28, 2026
7 of 32 checks passed
@tyrchen
tyrchen deleted the fix/lambda-prctl-compat branch February 28, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant