Skip to content

Fix tini zombie reaping with shared process namespace#4114

Merged
ahhda merged 1 commit intomainfrom
fix/tini-subreaper-shared-pid-namespace
Feb 3, 2026
Merged

Fix tini zombie reaping with shared process namespace#4114
ahhda merged 1 commit intomainfrom
fix/tini-subreaper-shared-pid-namespace

Conversation

@ahhda
Copy link
Copy Markdown
Contributor

@ahhda ahhda commented Feb 3, 2026

Summary

Adds the -s (subreaper) flag to tini in the Dockerfile entrypoint to fix zombie process reaping when shareProcessNamespace: true is set in Kubernetes deployments.

Problem

Our Kubernetes deployments use shareProcessNamespace: true to allow sidecar containers (like the memory monitor) to access /proc of the main process. However, this causes the following warning:

[WARN  tini (82)] Tini is not running as PID 1 and isn't registered as a child subreaper.
Zombie processes will not be re-parented to Tini, so zombie reaping won't work.
To fix the problem, use the -s option or set the environment variable TINI_SUBREAPER to register Tini as a child subreaper, or run Tini as PID 1.

When shareProcessNamespace is enabled, Kubernetes' pause container becomes PID 1 instead of tini:

PID 1: pause (Kubernetes infrastructure)
├── tini -- autopilot
│   └── autopilot
└── /bin/sh -c (memory-monitor sidecar)

Without PID 1 status, tini cannot reap zombie (orphaned) child processes by default.

Solution

The -s flag tells tini to register as a child subreaper via the PR_SET_CHILD_SUBREAPER prctl. This Linux kernel feature allows a non-PID-1 process to adopt and reap orphaned descendant processes, restoring proper zombie cleanup.

Add -s flag to tini to enable subreaper mode, which allows tini to
properly reap zombie processes when shareProcessNamespace is enabled
in Kubernetes deployments.
@ahhda ahhda requested a review from a team as a code owner February 3, 2026 08:57
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The change correctly adds the -s flag to tini in Dockerfile to address zombie process reaping in shared process namespaces. However, the fix is incomplete. The tini entrypoint in playground/Dockerfile (line 114) is also missing the -s flag, which will lead to the same zombie process reaping failure this PR aims to solve. To ensure consistent behavior and prevent resource leaks from zombie processes, the -s flag should also be added to playground/Dockerfile.

Copy link
Copy Markdown
Contributor

@squadgazzz squadgazzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Not sure if we need it in the playground/Dockerfile tho.

@jmg-duarte
Copy link
Copy Markdown
Contributor

Thanks! Not sure if we need it in the playground/Dockerfile tho.

I haven't run into any issues

@ahhda ahhda added this pull request to the merge queue Feb 3, 2026
Merged via the queue into main with commit 838fafe Feb 3, 2026
19 checks passed
@ahhda ahhda deleted the fix/tini-subreaper-shared-pid-namespace branch February 3, 2026 15:18
@github-actions github-actions bot locked and limited conversation to collaborators Feb 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants