Overview
| Artifact ID: | b06b9af25dcd9246b98960332456759a0b55a470361e09bf3ded33a3dc5081f5 |
|---|---|
| Ticket: | 9b63fd201b87c737ef375cd95b5ebbc79629c9ab
Fix Thread Join on WIndows |
| User & Date: | konrad.schwarz on 2023-02-20 21:20:43 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-plain"
- comment changed to:
The manual page for Thread states "Windows currently does not support joinable threads. This flag value is therefore ignored on this platform." A cursory look at the implementation shows that thread joining is implemented, but in a round-about way, using the ThreadJoin module that manages a list of joinable threads. The proper way to join a thread (i.e., synchronously wait for a thread's termination) in Win32 is to Wait (e.g., WaitForSingleObject()) on the thread handle, returned e.g. by the _beginthreadex() function. The thread's exit status can be retrieved with the Win32 GetExitCodeThread() function. While the thread is still running, this function will return a fixed value (259), but once the thread has exited (when the thread's handle has been signaled), the unadulterated (32-bit) exit code is returned by GetExitCodeThread(). (The MSDN documentation is poorly written, so missing this is quite understandable.) The current implementation closes this handle immediately, which is a mistake. If you like, I could probably provide a patch.
- foundin changed to: "All"
- is_private changed to: "0"
- login: "konrad.schwarz"
- priority changed to: "5 Medium"
- private_contact changed to: "80ea11e9d893f90ae1b5d3c2e6c94600b62863e9"
- resolution changed to: "None"
- severity changed to: "Important"
- status changed to: "Open"
- submitter changed to: "konrad.schwarz"
- subsystem changed to: "80. Thread Package"
- title changed to: "Fix Thread Join on WIndows"
- type changed to: "Bug"