Windows terminal shutdown last process but not the main one #17949

Closed
opened 2026-01-31 05:59:21 +00:00 by claunia · 1 comment
Owner

Originally created by @CovERUshKA on GitHub (Jul 16, 2022).

Windows Terminal version

1.13.11432.0

Windows build number

10.0.22000.613

Other Software

No response

Steps to reproduce

  1. Compile console apps infinite.exe and main.exe Release x64 Visual Studio 2022
  2. Place them in the same folder
  3. Run main.exe
  4. Close console window
  5. main.exe will still work but without console window because GetConsoleWindow() returns 0

infinite.exe

int main(int argc, TCHAR *argv[])
{
    Sleep(999999);

    return 0;
}

main.exe

int main(int argc, TCHAR *argv[])
{
    static STARTUPINFOA si;
    static PROCESS_INFORMATION pi;

    ZeroMemory(&si, sizeof(si));
    ZeroMemory(&pi, sizeof(pi));

    CreateProcessA("infinite.exe",
    NULL,
    NULL,
    NULL,
    TRUE,
    NULL,
    NULL,
    NULL,
    &si,
        &pi);

    // Wait until child process exits.
    WaitForSingleObject(pi.hProcess, INFINITE);

    // Close process and thread handles.
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);

    MessageBoxA(0, "I'm still working", "You know", MB_OK);

    return 0;
}

Expected Behavior

When i close console window i expect that it wil shutdown the main process and subprocesses

Actual Behavior

When i close console window it shutdowns only the last subprocess but not the main process

Originally created by @CovERUshKA on GitHub (Jul 16, 2022). ### Windows Terminal version 1.13.11432.0 ### Windows build number 10.0.22000.613 ### Other Software _No response_ ### Steps to reproduce 1) Compile console apps infinite.exe and main.exe Release x64 Visual Studio 2022 2) Place them in the same folder 3) Run main.exe 4) Close console window 5) main.exe will still work but without console window because GetConsoleWindow() returns 0 infinite.exe ``` int main(int argc, TCHAR *argv[]) { Sleep(999999); return 0; } ``` main.exe ``` int main(int argc, TCHAR *argv[]) { static STARTUPINFOA si; static PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); ZeroMemory(&pi, sizeof(pi)); CreateProcessA("infinite.exe", NULL, NULL, NULL, TRUE, NULL, NULL, NULL, &si, &pi); // Wait until child process exits. WaitForSingleObject(pi.hProcess, INFINITE); // Close process and thread handles. CloseHandle(pi.hProcess); CloseHandle(pi.hThread); MessageBoxA(0, "I'm still working", "You know", MB_OK); return 0; } ``` ### Expected Behavior When i close console window i expect that it wil shutdown the main process and subprocesses ### Actual Behavior When i close console window it shutdowns only the last subprocess but not the main process
claunia added the Needs-TriageIssue-BugNeeds-Tag-Fix labels 2026-01-31 05:59:22 +00:00
Author
Owner

@CovERUshKA commented on GitHub (Jul 16, 2022):

Fixed in preview version

@CovERUshKA commented on GitHub (Jul 16, 2022): Fixed in preview version
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17949