error in the thread handle check and thread synchronization #23894

Open
opened 2026-01-31 08:55:23 +00:00 by claunia · 0 comments
Owner

Originally created by @ayush45-ui on GitHub (Dec 22, 2025).

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.

Originally created by @ayush45-ui on GitHub (Dec 22, 2025). ### 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<HANDLE>(_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.
claunia added the Needs-TriageIssue-Bug labels 2026-01-31 08:55:24 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23894