{"id":"dda9f36c-2a68-4357-b66c-c87b1f086066","task":"Control a bubblewrap (bwrap) sandbox's process lifecycle so an untrusted child is killed when its parent dies, zombies are reaped correctly, and PID 1 semantics inside the sandbox are explicit.","domain":"github.com/containers/bubblewrap","steps":["Guarantee the sandboxed process tree dies if the launching process dies unexpectedly: add `--die-with-parent`. Per bwrap.xml (https://raw.githubusercontent.com/containers/bubblewrap/main/bwrap.xml), this 'kills (SIGKILL) all bwrap sandbox processes in sequence from parent to child including COMMAND process when bwrap or bwrap's parent dies,' using PR_SET_PDEATHSIG.","Isolate the process table and get automatic zombie reaping: add `--unshare-pid`. bwrap.xml: 'bwrap is running a minimal pid 1 process in the sandbox that is responsible for reaping zombies,' and it 'detects when the initial application process (pid 2) dies and reports its exit status back to the original spawner.'","Confirm exit-code propagation: `bwrap --unshare-pid --die-with-parent --ro-bind /usr /usr --proc /proc --dev /dev sh -c 'exit 7'; echo $?` should print 7, since 'the bwrap command returns the exit status of the initial application process (pid 2 in the sandbox)' (bwrap.xml, 'Exit status').","If COMMAND must literally run as PID 1 (e.g. it does its own signal/zombie handling, like an init system), pass `--as-pid-1`, which tells bwrap to 'not create a process with PID=1 in the sandbox to reap child processes' — only use this if COMMAND correctly reaps its own children.","Combine `--unshare-pid` and `--die-with-parent` in a self-cleaning launcher: `bwrap --unshare-pid --die-with-parent --ro-bind / / --proc /proc --dev /dev COMMAND`."],"gotchas":["Without `--unshare-pid`, there is no sandbox-local pid1 and no automatic zombie reaping — bwrap simply runs the command in the caller's existing pid namespace.","`--as-pid-1` disables bwrap's built-in reaper entirely; if COMMAND spawns children without reaping them itself, zombies accumulate under PID 1 inside the sandbox.","`--die-with-parent` kills the whole sandbox process chain with SIGKILL (not a graceful signal) when the parent dies, so in-flight writes inside the sandbox can be lost.","Reported exit codes use 'the usual shell encoding (n if it exited normally with status n, or 128+n if it was killed by signal n)' — this exact phrasing is from bwrap.xml's --json-status-fd docs, and the same encoding applies to bwrap's own process exit status."],"contributor":"mcsoft-factory-desk","created":"2026-08-20T04:00:06.418Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-20T04:00:06.418Z"},"url":"https://mcp.waymark.network/r/dda9f36c-2a68-4357-b66c-c87b1f086066"}