Repository navigation
Description
Summary
Sandbox sessions can accumulate zombie processes whose PPID is already 1, but they are not reaped by PID 1. Over time they stack up and can contribute to hitting the sandbox process limit (pids.max).
This does not look like a normal user-script leak anymore, because these are already orphaned zombies under PID 1.
Environment
- OpenClaw: v2026.4.15
- Runtime: sandboxed Docker session
- Host: Linux arm64 / OrbStack VM on Apple Silicon
What I observed
Repeated checks inside the sandbox showed zombies like these:
count 23
10448 1 bash
23857 1 sh
44348 1 sh
52955 1 bash
74031 1 bash
74042 1 bash
74388 1 bash
75421 1 bash
83271 1 bash
84642 1 bash
90986 1 bash
98612 1 bash
106630 1 bash
124027 1 git
125371 1 bash
133905 1 git
146115 1 sort
146116 1 sort
146119 1 sort
146120 1 sort
146124 1 sort
146125 1 sort
150588 1 bash
Summary by command:
bash 13
sort 6
sh 2
git 2
Current process health at the time:
📊 Processes: 3 alive, 23 zombie, 26 total
Why this seems like a runtime / PID 1 issue
- These are already zombies, so
kill -9is not meaningful. - Their
PPIDis already1. - If PID 1 were reaping correctly, they should disappear.
- Instead, they persist and accumulate.
That suggests the sandbox init / PID 1 / process supervision layer is not reaping all orphaned children.
Impact
- Zombie count can keep climbing across normal tool/script usage.
- This risks exhausting the sandbox process budget (
pids.max). - Once process slots get tight, random commands, cron jobs, and tool executions can start failing in hard-to-explain ways.
We previously saw sandbox pressure around pids.max = 256, so this is not purely cosmetic.
Likely triggers
The zombies appear to come from normal shell-heavy activity, including things like:
bash/sh- shell pipelines involving
sort git- cron/script execution paths
So this may be reproducible with ordinary agent workloads, not only unusual manual commands.
Expected behavior
Orphaned zombie children adopted by PID 1 should be reaped promptly.
Actual behavior
Zombie processes with PPID=1 remain visible indefinitely and accumulate over time.
Optional follow-up
If useful, I can help capture a smaller repro focused on shell pipeline + orphaning behavior inside the sandbox.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
mjamiv commentedon Apr 19, 2026
Negative-repro datapoint to help bound this: a 2026.4.11 deployment running under a watchdog supervisor with gateway respawn disabled shows 0 PID-1 zombies after ~20h continuous uptime. If the original repro can be correlated with gateway respawn/restart churn rather than steady-state subprocess lifecycle, that may narrow the surface considerably.
aaajiao commentedon Apr 24, 2026
Thanks, that datapoint is useful.
One likely difference in our environment is that we make heavy use of sub-agents. My suspicion is that the resident zombies are mostly produced after sub-agent runs / sub-agent-adjacent shell activity, rather than by steady-state gateway uptime alone.
So this may not reproduce on a quiet 2026.4.11 deployment with gateway respawn disabled, but may show up under normal agent workloads where sub-agents spawn shell-heavy tasks and then exit. In our case the zombies were already adopted by PID 1, so the issue looked less like an individual command leak and more like orphaned subprocesses from completed/aborted sub-agent work not being reaped.
If helpful, I can try to capture a smaller repro around:
psforSTAT=ZwithPPID=1aaajiao commentedon Apr 25, 2026
Additional observation from today:
In the sandbox, PID 1 is currently
sleep infinity, not an init/reaper process. All remaining zombies I inspected are already underPPID=1, so they cannot be cleared from userspace.One useful data point: I had a few orphaned
python3 -m http.serverpreview processes. After terminating them, alive process count dropped, but zombie count increased (6 -> 9). So an automatic “kill orphan processes” health check can actually make the zombie count worse when PID 1 does not reap children.Current conclusion:
PPID=1zombies persist until the sandbox/container is restarted;This narrows my earlier suspicion: sub-agents may be a workload amplifier, but the underlying issue is that orphaned children adopted by PID 1 are not being reaped.
clawsweeper commentedon Apr 30, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 28, 2026, 12:07 AM ET / 04:07 UTC.
Summary
Current main and the latest release still create Docker sandbox containers without
--initand runsleep infinityas PID 1, so the reported PID-1 zombie accumulation remains valid. The direct init fix and the create-args hash rollout are already covered by open PRs, so this should stay open for maintainer coordination rather than another independent fix PR.Reproducibility: yes. for source reproduction: current main still runs Docker sandbox containers as
sleep infinitywithout Docker--init, matching the reported unreapedPPID=1zombie condition. I did not run a mutable long-duration Docker workload in this read-only review.Root-cause cluster
Relationship:
canonicalCanonical: #68691
Summary: This issue is the canonical open report for Docker sandbox PID-1 zombie reaping; related open PRs are fix candidates, while the merged runtime-image tini PR covers an adjacent but different Docker surface.
Members:
fixed_by_candidate: fix(sandbox): pass --init so tini reaps zombie processes #74083 - Open PR proposes adding Docker--initto sandbox create args, directly targeting the reported PID-1 zombie issue for newly created sandboxes.partial_overlap: fix(sandbox): bump config hash when buildSandboxCreateArgs flags change #76590 - Open PR proposes the create-args hash epoch needed for existing long-running containers to pick up future Docker flag changes, but it intentionally does not add the init flag itself.adjacent_distinct: Container accumulates zombie processes — needs tini or --init as PID 1 wrapper #77885 - Closed issue concerned the main OpenClaw Docker runtime image running as PID 1, not agent-created sandbox containers.adjacent_distinct: feat(docker): integrate tini as PID 1 init wrapper to reap zombie processes #78777 - Merged PR fixed the main runtime Docker image tini entrypoint and docs, but did not modify sandbox container create args.partial_overlap: Bug: Zombie processes accumulate in worker containers after child process exits #79909 - Closed worker-container zombie report shares the zombie-reaping theme but described a HiClaw worker image/process surface rather than the OpenClaw sandboxsleep infinityPID-1 path.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
Open PRs already cover the direct sandbox
--initchange and the hash rollout mechanism, so maintainers should review, coordinate, or replace that work instead of queueing another independent fix PR.Review details
Best possible solution:
Land a coordinated sandbox fix that runs Docker sandbox containers under an init/reaper process and includes a compatible recreate path for existing long-running containers.
Do we have a high-confidence way to reproduce the issue?
Yes for source reproduction: current main still runs Docker sandbox containers as
sleep infinitywithout Docker--init, matching the reported unreapedPPID=1zombie condition. I did not run a mutable long-duration Docker workload in this read-only review.Is this the best way to solve the issue?
Yes in direction: the maintainable fix belongs at the sandbox container creation and reuse boundary, using Docker init plus create-args hash invalidation. Userland killing is not the best fix because the reporter observed it can increase zombies when PID 1 does not reap them.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 1b0766080a30.
Label changes
Label justifications:
P1: The issue can exhaust sandbox process slots in long-running agent workloads and break normal tool execution.impact:crash-loop: The reported zombie accumulation can lead to process-table exhaustion and sandbox command failures, which is a process-level availability risk.Evidence reviewed
Acceptance criteria:
src/agents/sandbox/docker.ts.node scripts/run-vitest.mjs src/agents/sandbox-create-args.test.ts src/agents/sandbox/docker.config-hash-recreate.test.ts src/agents/sandbox/config-hash.test.ts.PPID=1zombies.What I checked:
AGENTS.md:1, 1b0766080a30)buildSandboxCreateArgsstarts withdocker create --name ...and appends labels, security, resource, and mount flags, but there is no--initflag in the current create-args path. (src/agents/sandbox/docker.ts:428, 1b0766080a30)sleep infinity, matching the reporter's observation that PID 1 is not an init/reaper process. (src/agents/sandbox/docker.ts:568, 1b0766080a30)src/agents/sandbox/config-hash.ts:17, 1b0766080a30)src/agents/sandbox/prune.ts:56, 1b0766080a30)scope: "agent", DockerpidsLimit: 256, and prune settings, which aligns with the issue's long-running sandbox plus process-limit risk. Public docs:docs/gateway/config-agents.md. (docs/gateway/config-agents.md:803, 1b0766080a30)Likely related people:
docker createandsleep infinitypaths. (role: recent area contributor; confidence: high; commits: 6f1076351cbe; files:src/agents/sandbox/docker.ts,src/agents/sandbox/config-hash.ts,src/agents/sandbox/prune.ts)src/agents/sandbox/docker.ts,src/agents/sandbox/config-hash.ts,src/agents/sandbox/prune.ts)src/agents/sandbox/browser.ts,src/agents/sandbox/config-hash.ts)Dockerfile,docs/install/docker.md,docs/install/fly.md)--initPR that targets the same PID-1 reaping issue; this is routing context rather than current-main ownership. (role: open fix candidate author; confidence: medium; commits: 51dbb5e8dba7; files:src/agents/sandbox/docker.ts,src/agents/sandbox-create-args.test.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.openclaw-barnacle commentedon Jun 3, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.
steipete commentedon Jul 10, 2026
Fixed on
mainby #103441 inf698703934f.Docker now starts ordinary and browser sandbox containers with its built-in init process. A shared create-arguments epoch rolls the change out through both configuration hashes while preserving active containers and the existing explicit recreate hint. Real Docker proof showed the negative control retain one zombie, while the fixed path reported
HostConfig.Init=true, PID 1docker-init, and zero zombies after the same orphan-grandchild scenario. Cold recreation, hot deferral, 63 focused tests, and exact-head CI run 29072559013 passed.