fix(docker): --init for zombie reaping + sleep infinity for idle-based lifetime - #6910
Closed
malaiwah wants to merge 1 commit into
Closed
fix(docker): --init for zombie reaping + sleep infinity for idle-based lifetime#6910malaiwah wants to merge 1 commit into
malaiwah wants to merge 1 commit into
Conversation
…d lifetime Two issues with sandbox container spawning: 1. PID 1 was `sleep 2h` which doesn't call wait() — every background process that exited became a zombie (<defunct>), and the process tool reported them as "running" because zombie PIDs still exist in the process table. Fix: add --init to docker run, which uses tini (Docker) or catatonit (Podman) as PID 1 to reap children automatically. Both runtimes support --init natively. 2. The fixed 2-hour lifetime was arbitrary and sometimes too short for long agent sessions. Fix: replace 'sleep 2h' with 'sleep infinity'. The idle reaper (_cleanup_inactive_envs, gated by terminal.lifetime_seconds, default 300s) already handles cleanup based on last activity timestamp — there's no need for the container itself to have a fixed death timer. Fixes NousResearch#6908.
Contributor
|
Merged via PR #7407. Cherry-picked with authorship preserved. Clean fix — thanks! |
This was referenced Apr 10, 2026
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6908.
Problem
Sandbox containers spawned by the Docker backend have two issues:
Zombie accumulation. PID 1 is
sleep 2h, which doesn't callwait(). Every background process (terminal(background=true)) that exits becomes a zombie. Theprocesstool reports them as "running" because zombie PIDs still exist in the process table.Fixed 2-hour lifetime. Arbitrary and sometimes too short for long agent sessions. The idle reaper (
_cleanup_inactive_envs, gated byterminal.lifetime_seconds) already handles cleanup based on last activity — the container doesn't need its own death timer.Fix
Two one-line changes:
docker runflags--init— tini (Docker) / catatonit (Podman) as PID 1, reaps zombiessleep 2hsleep infinity— no fixed lifetime, idle reaper handles itBoth Docker and Podman support
--initnatively.sleep infinityis POSIX (GNU coreutils). The idle reaper'sterminal.lifetime_seconds(default 300s) controls when inactive containers are cleaned up.Verification
Tested on Podman 5.x (Alpine LXC):
podman run --rm --init <image> sh -c "sleep 10 & wait"— no zombiesprocess(action="list")reflects actual state