Skip to content

cmd: workaround conpty race condition in Start() - #2923

Open
mcayland-ntx wants to merge 1 commit into
microsoft:mainfrom
mcayland-ntx:fix/avoid-conpty-race-with-no-stdin
Open

cmd: workaround conpty race condition in Start()#2923
mcayland-ntx wants to merge 1 commit into
microsoft:mainfrom
mcayland-ntx:fix/avoid-conpty-race-with-no-stdin

Conversation

@mcayland-ntx

Copy link
Copy Markdown

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.

Resolves #2831

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>
@mcayland-ntx
mcayland-ntx requested a review from a team as a code owner September 8, 2026 11:59
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.

Stdin handle required to avoid conpty race condition upon WCOW container startup with terminal

1 participant