From f2ec7be5e026b85e580b2f659b5a554dc7262ece Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Tue, 8 Sep 2026 12:44:24 +0100 Subject: [PATCH] cmd: always create Stdin pipe when using a terminal in Start() conpty has a known race condition when attaching a terminal to a starting process that does not have a Stdin handle, causing the process to exit immediately with a 0xc000013a (STATUS_CONTROL_C_EXIT) error. This is easily noticed when launching a container using nerdctl in detached terminal mode which uses BinaryIO where only the Stdout and Stderr handles are created for the target process. Attempting to start a target process in this configuration results in a process start success rate of less than 5%. Since the race condition in conpty is unlikely to be fixed in the short term, add a workaround to ensure that a Stdin handle is always created for container processes launched with terminal mode enabled. This allows a container started using nerdctl in detached terminal mode to always start successfully. Signed-off-by: Mark Cave-Ayland --- internal/cmd/cmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 82f859d5b0..37bff29711 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -180,7 +180,7 @@ func (c *Cmd) Start() error { User: c.Spec.User.Username, WorkingDirectory: c.Spec.Cwd, EmulateConsole: c.Spec.Terminal, - CreateStdInPipe: c.Stdin != nil, + CreateStdInPipe: c.Stdin != nil || c.Spec.Terminal, CreateStdOutPipe: c.Stdout != nil, CreateStdErrPipe: c.Stderr != nil, }