Skip to content

error in the thread handle check and thread synchronization #19672

@ayush45-ui

Description

@ayush45-ui

Windows Terminal version

No response

Windows build number

No response

Other Software

No response

Steps to reproduce

Add thread creation error checking - Verifies _beginthread() didn't return -1
Fixe process handle cleanup - Only closes handles if CreateProcess succeeded
Improve thread synchronization - Closes output pipe to signal EOF, then waits for listener thread to complete

Expected Behavior

No response

Actual Behavior

Thread Handle Check--
cppHANDLE hPipeListenerThread{ reinterpret_cast(_beginthread(PipeListener, 0, hPipeIn)) };
_beginthread() returns (uintptr_t)-1 on error, but there's no error checking before proceeding.
Process Handle Cleanup--
The code closes piClient.hThread and piClient.hProcess even if CreateProcess failed, which could close invalid handles.
Thread Synchronization--
Using Sleep(500) is unreliable for thread synchronization. The listener thread may still be running when cleanup begins.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIt either shouldn't be doing this or needs an investigation.Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions