Skip to content

Commit f2ec7be

Browse files
committed
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 <mark.caveayland@nutanix.com>
1 parent 4712998 commit f2ec7be

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎internal/cmd/cmd.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (c *Cmd) Start() error {
180180
User: c.Spec.User.Username,
181181
WorkingDirectory: c.Spec.Cwd,
182182
EmulateConsole: c.Spec.Terminal,
183-
CreateStdInPipe: c.Stdin != nil,
183+
CreateStdInPipe: c.Stdin != nil || c.Spec.Terminal,
184184
CreateStdOutPipe: c.Stdout != nil,
185185
CreateStdErrPipe: c.Stderr != nil,
186186
}

0 commit comments

Comments
 (0)