| Ticket UUID: | 9b63fd201b87c737ef375cd95b5ebbc79629c9ab | ||
| Title: | Fix Thread Join on WIndows | ||
| Type: | Bug | Created on: | 2023-02-20 21:20:43 |
| Submitter: | konrad.schwarz | Assigned to: | nobody |
| Subsystem: | 80. Thread Package | Severity: | Important |
| Priority: | 5 Medium | Last modified: | 2023-03-29 08:59:56 |
| Status: | Open | Closed by: | nobody |
| Resolution: | None | Closed on: | |
| Version: | All | ||
| Description: | ||||
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. | ||||
| User Comments: | ||||
jan.nijtmans added on 2023-02-21 07:35:48:
Is this ticket meant for the Thread package or for Tcl itself? See: https://core.tcl-lang.org/thread. Whatever it's meant for, yes, a patch would help a lot! konrad.schwarz (claiming to be Konrad Schwarz) added on 2023-03-28 19:09:48:
Patch has been added. konrad.schwarz added on 2023-03-29 08:59:56:
Sorry, I misunderstood the fossil patch mechanism. I was expected it to include commits, but in fact it includes only un-committed changes. How do I communicate my changes back to you? Can I push to the main Tcl repo? | ||||
Attachments:
- thread_join_win32.patch [download] added by konrad.schwarz on 2023-03-28 19:08:41. [details]
