Skip to content

cmd/containerd-shim-runhcs-v1: prevent zombie shims by adding timeout to stdin read#2824

Open
HarshalPatel1972 wants to merge 1 commit into
microsoft:mainfrom
HarshalPatel1972:fix-zombie-shim
Open

cmd/containerd-shim-runhcs-v1: prevent zombie shims by adding timeout to stdin read#2824
HarshalPatel1972 wants to merge 1 commit into
microsoft:mainfrom
HarshalPatel1972:fix-zombie-shim

Conversation

@HarshalPatel1972

Copy link
Copy Markdown

cmd/containerd-shim-runhcs-v1: prevent zombie shims by adding timeout to stdin read

When the containerd daemon restarts or exits unexpectedly on Windows, the
named pipe write handles may be inherited or fail to immediately broadcast
an EOF. Because io.ReadAll does not natively respect context.Context,
the runhcs shim blocks indefinitely waiting for data, leaking the process
and blocking network ports.

This introduces a background monitor with a 5-second timeout that explicitly
closes os.Stdin if the read takes too long. This forcefully aborts the blocking
I/O read, allowing the shim to detect the daemon disconnection and
terminate gracefully.

Signed-off-by: Harshal Patel hp842484@gmail.com

… to stdin read

When the containerd daemon restarts or exits unexpectedly on Windows, the
named pipe write handles may be inherited or fail to immediately broadcast
an EOF. Because io.ReadAll does not natively respect context.Context,
the runhcs shim blocks indefinitely waiting for data, leaking the process
and blocking network ports.

This introduces a background monitor with a 5-second timeout that explicitly
closes os.Stdin if the read takes too long. This forcefully aborts the blocking
I/O read, allowing the shim to detect the daemon disconnection and
terminate gracefully.

Signed-off-by: Harshal Patel <hp842484@gmail.com>
@HarshalPatel1972 HarshalPatel1972 requested a review from a team as a code owner July 13, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant