Skip to content

Bug: Zombie processes accumulate in worker containers after child process exits #79909

Closed as not planned

Description

@lijinxiao1982

Bug Description

After running HiClaw workers for a period of time, zombie processes accumulate in each worker container. Each worker container typically has 2 zombie processes:

  1. [worker-entrypoi] - the worker entrypoint script
  2. [hiclaw] - the hiclaw CLI process

Root Cause Analysis

The openclaw-gateway process inside worker containers spawns child processes (worker-entrypoint and hiclaw) but does not properly handle SIGCHLD signals to reap exited child processes.

Evidence

# Zombie process distribution (15 workers x 2 zombies each + 3 from manager)
$ ps aux | awk '$8=="Z"' | wc -l
32

# Each worker has 2 zombies:
$ docker exec hiclaw-worker-data-engineer ps aux | awk '$8=="Z"'
PID   PPID  STAT  COMMAND
143   0     Z     [worker-entrypoi]
199   0     Z     [hiclaw]

# Parent processes are openclaw-gateway:
$ ps -eo pid,ppid,stat,comm | awk '$3 ~ /^Z/ {print $2}' | sort | uniq -c
      2 163193  (openclaw-gateway)
      2 164766  (openclaw-gateway)
      ...

Impact

  • Zombie processes do not consume CPU or memory
  • They occupy entries in the process table (currently 32/4,194,304)
  • Long-term accumulation could eventually exhaust the process table
  • No functional impact at current levels

Workaround

Restarting worker containers clears the zombie processes temporarily.

Environment

  • HiClaw Version: latest (hiclaw-worker:latest)
  • OS: Ubuntu 26.04 LTS (host)
  • Kernel: 7.0.0-15-generic

Suggested Fix

The openclaw-gateway process should:

  1. Install a SIGCHLD signal handler
  2. Call waitpid(-1, NULL, WNOHANG) in a loop to reap all exited children
  3. Or use signal(SIGCHLD, SIG_IGN) to auto-reap children

Reproduction Steps

  1. Start HiClaw with multiple workers
  2. Wait for workers to execute tasks (which spawn child processes)
  3. Observe zombie processes accumulating in worker containers

Activity

  1. clawsweeper commented on May 9, 2026

    @clawsweeper
    Contributor

    Thanks for writing this up. I checked the repo boundary, and this lives outside the OpenClaw source shell.

    Close because the reported HiClaw worker image and process names are outside the OpenClaw source tree, while the repo-owned Docker runtime already has init-backed zombie reaping on current main.

    So I’m closing this as outside the OpenClaw source repository rather than keeping it open as core work.

    Review details

    Best possible solution:

    Keep OpenClaw's init-backed container runtime as-is; fix any HiClaw worker-specific reaping bug in that external worker image or refile with a current OpenClaw-owned reproduction.

    Do we have a high-confidence way to reproduce the issue?

    No. The report includes process-list evidence for hiclaw-worker:latest, but current OpenClaw main contains no HiClaw worker or worker-entrypoint surface and the maintained Docker runtime already enables init-backed reaping.

    Is this the best way to solve the issue?

    Not applicable as an OpenClaw source fix. The narrow maintainable path is external HiClaw worker-image repair, or a new current OpenClaw Docker reproduction that bypasses the existing tini/init setup.

    Security review:

    Security review: No patch was proposed, and this is not a security-sensitive issue report.

    What I checked:

    Likely related people:

    • VintageAyu: Authored the merged Docker runtime change that runs the image under tini and updated the Docker docs covering zombie reaping. (role: recent Docker runtime init contributor; confidence: high; commits: e63e4f9551e9, f9da4843652e; files: Dockerfile, docker-compose.yml, docs/install/docker.md)
    • steipete: Recent history shows repeated Dockerfile, Docker docs, and runtime packaging work around the maintained container boundary relevant to this report. (role: recent Docker/runtime maintainer; confidence: medium; commits: 330ba1fa3194, ed8f50f240a8, a3bbcf2792b1; files: Dockerfile, docker-compose.yml, docs/install/docker.md)
    • sallyom: Recent Docker history includes Docker docs/runtime-image changes and reviewer context on container setup changes adjacent to the maintained Docker path. (role: adjacent Docker packaging reviewer/contributor; confidence: medium; commits: 484a289be34e, e8258fd4a6eb; files: Dockerfile, docs/install/docker.md)

    Codex review notes: model gpt-5.5, reasoning high; reviewed against cb86388cec19.

  2. locked as resolved and limited conversation to collaborators on May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions