Shell exits after processed input enabled by child process #23287

Closed
opened 2026-01-31 08:37:45 +00:00 by claunia · 4 comments
Owner

Originally created by @hpjansson on GitHub (May 22, 2025).

Windows Terminal version

1.22.11141.0

Windows build number

10.0.19045.0

Other Software

Using the MXE cross build environment to build a console program on Linux targeting Windows x86_64-w64-mingw32.static.

Steps to reproduce

Compile and run the following C program:

#include <windows.h>
#include <io.h>

int
main (int argc, char *argv [])
{
    HANDLE chd = GetStdHandle (STD_INPUT_HANDLE);

    if (chd != INVALID_HANDLE_VALUE)
    {
        DWORD bitmask = ENABLE_PROCESSED_INPUT | ENABLE_VIRTUAL_TERMINAL_INPUT;
        SetConsoleMode (chd, bitmask);
    }

    return 0;
}

Expected Behavior

I'm returned to the shell prompt where I can keep working.

Actual Behavior

The program exits as normal and I get the PS prompt. There's a brief pause, and then the shell exits with code 2.

I'm only seeing this in the latest stable release of WT. The preview version works fine, as do other CLIs (Alacritty, Wezterm, cmd.exe, MSYS2/zsh).

This was first observed by a user of my application: https://github.com/hpjansson/chafa/issues/283#issuecomment-2897707684. It's possible I'm doing something wrong here, or I can work around it somehow, but I haven't found a way so far.

If it turns out this is a real issue, maybe a backport of the fixed code in WT Preview is warranted. I've looked for the fix in the issues and release notes, but unfortunately couldn't find anything that mentioned addressing this specifically.

Originally created by @hpjansson on GitHub (May 22, 2025). ### Windows Terminal version 1.22.11141.0 ### Windows build number 10.0.19045.0 ### Other Software Using the MXE cross build environment to build a console program on Linux targeting Windows `x86_64-w64-mingw32.static`. ### Steps to reproduce Compile and run the following C program: ```c #include <windows.h> #include <io.h> int main (int argc, char *argv []) { HANDLE chd = GetStdHandle (STD_INPUT_HANDLE); if (chd != INVALID_HANDLE_VALUE) { DWORD bitmask = ENABLE_PROCESSED_INPUT | ENABLE_VIRTUAL_TERMINAL_INPUT; SetConsoleMode (chd, bitmask); } return 0; } ``` ### Expected Behavior I'm returned to the shell prompt where I can keep working. ### Actual Behavior The program exits as normal and I get the PS prompt. There's a brief pause, and then the shell exits with code 2. I'm only seeing this in the latest stable release of WT. The preview version works fine, as do other CLIs (Alacritty, Wezterm, cmd.exe, MSYS2/zsh). This was first observed by a user of my application: https://github.com/hpjansson/chafa/issues/283#issuecomment-2897707684. It's possible I'm doing something wrong here, or I can work around it somehow, but I haven't found a way so far. If it turns out this is a real issue, maybe a backport of the fixed code in WT Preview is warranted. I've looked for the fix in the issues and release notes, but unfortunately couldn't find anything that mentioned addressing this specifically.
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 08:37:46 +00:00
Author
Owner

@hpjansson commented on GitHub (May 22, 2025):

I can provide an executable built from the above snippet if needed.

@hpjansson commented on GitHub (May 22, 2025): I can provide an executable built from the above snippet if needed.
Author
Owner

@DHowett commented on GitHub (May 22, 2025):

5c55144c28cbe978f2a3654d688703bd8d1325e5 is the first fixed commit
commit 5c55144c28cbe978f2a3654d688703bd8d1325e5
Author: Leonard Hecker <lhecker@microsoft.com>
Date:   Tue Dec 3 13:12:46 2024 -0800

    Properly implement WaitForData for ReadConsoleInput (#18228)

I should have guessed it was #18228. :)

@DHowett commented on GitHub (May 22, 2025): ``` 5c55144c28cbe978f2a3654d688703bd8d1325e5 is the first fixed commit commit 5c55144c28cbe978f2a3654d688703bd8d1325e5 Author: Leonard Hecker <lhecker@microsoft.com> Date: Tue Dec 3 13:12:46 2024 -0800 Properly implement WaitForData for ReadConsoleInput (#18228) ``` I should have guessed it was #18228. :)
Author
Owner

@DHowett commented on GitHub (May 22, 2025):

Oh, good news! It's in our "to be shipped" queue for 1.22 already. Keep your eyes peeled for a new version!

/dup #15859

@DHowett commented on GitHub (May 22, 2025): Oh, good news! It's in our "to be shipped" queue for 1.22 already. Keep your eyes peeled for a new version! /dup #15859
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (May 22, 2025):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@microsoft-github-policy-service[bot] commented on GitHub (May 22, 2025): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report! <!-- Policy app identification https://img.shields.io/static/v1?label=PullRequestIssueManagement. -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23287