Kit containers do not reap orphaned processes: no Docker init, no SIGCHLD handling #1382

Closed
opened 2026-10-27 13:40:10 +00:00 by sam · 0 comments
Owner

What is wrong

internal/container/kit.go creates the Kit container with Config.User "0" and a HostConfig that sets only NetworkMode, Binds and Mounts. Nothing in the tree handles SIGCHLD, sets PR_SET_CHILD_SUBREAPER, or calls Wait4(-1).

archie-agent is the container's PID 1. Any process it does not itself wait on, and which is orphaned, reparents to PID 1 and becomes a zombie when it exits.

How it is reached

  • runHook starts a background install/startup hook with ExecStart{Detach: true} (internal/container/kit.go). A detached hook that forks and exits leaves its children to PID 1.
  • Any interactive execution added later (an operator takeover shell) spawns arbitrary processes by construction.

Impact

Zombie accumulation inside a long-lived container. The container's PID table is finite, so the failure is delayed and shows up as fork failures in the agent, not as a clear error.

Fix

Set HostConfig.Init = true so Docker runs its own minimal init as PID 1 and reaps orphans; no tini needs to be bundled into the image. Alternatively reap in the worker, but Docker's init is the smaller change.

Evidence

  • grep for SIGCHLD, PR_SET_CHILD_SUBREAPER and syscall.Wait4 across internal/ and cmd/ returns nothing.
  • internal/container/kit.go HostConfig carries NetworkMode, Binds and Mounts only; Config.User is "0".

Acceptance criteria

a Kit container that orphans a background process reaps it (no zombie accumulation), or the worker reaps orphans itself.

Close reason

Verified: fixed in code or doc/file no longer exists (see burndown 2026-10-13)


Imported from beads archie-core-in4q · GitHub #1556 · type bug · priority P2 · created 2026-10-08 · closed 2026-10-12

## What is wrong internal/container/kit.go creates the Kit container with Config.User "0" and a HostConfig that sets only NetworkMode, Binds and Mounts. Nothing in the tree handles SIGCHLD, sets PR_SET_CHILD_SUBREAPER, or calls Wait4(-1). archie-agent is the container's PID 1. Any process it does not itself wait on, and which is orphaned, reparents to PID 1 and becomes a zombie when it exits. ## How it is reached - runHook starts a background install/startup hook with ExecStart{Detach: true} (internal/container/kit.go). A detached hook that forks and exits leaves its children to PID 1. - Any interactive execution added later (an operator takeover shell) spawns arbitrary processes by construction. ## Impact Zombie accumulation inside a long-lived container. The container's PID table is finite, so the failure is delayed and shows up as fork failures in the agent, not as a clear error. ## Fix Set HostConfig.Init = true so Docker runs its own minimal init as PID 1 and reaps orphans; no tini needs to be bundled into the image. Alternatively reap in the worker, but Docker's init is the smaller change. ## Evidence - grep for SIGCHLD, PR_SET_CHILD_SUBREAPER and syscall.Wait4 across internal/ and cmd/ returns nothing. - internal/container/kit.go HostConfig carries NetworkMode, Binds and Mounts only; Config.User is "0". ### Acceptance criteria a Kit container that orphans a background process reaps it (no zombie accumulation), or the worker reaps orphans itself. ### Close reason Verified: fixed in code or doc/file no longer exists (see burndown 2026-10-13) --- _Imported from beads `archie-core-in4q` · GitHub #1556 · type bug · priority P2 · created 2026-10-08 · closed 2026-10-12_
sam added the mediumbug labels 2026-10-27 13:40:10 +00:00
sam self-assigned this 2026-10-27 13:40:10 +00:00
sam closed this issue 2026-10-27 13:40:10 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#1382