-
Notifications
You must be signed in to change notification settings - Fork 9k
Description
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.