Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b06b9af25dcd9246b98960332456759a0b55a470361e09bf3ded33a3dc5081f5
Ticket: 9b63fd201b87c737ef375cd95b5ebbc79629c9ab
Fix Thread Join on WIndows
User & Date: konrad.schwarz on 2023-02-20 21:20:43
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-plain"
  4. 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.
    
  5. foundin changed to: "All"
  6. is_private changed to: "0"
  7. login: "konrad.schwarz"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "80ea11e9d893f90ae1b5d3c2e6c94600b62863e9"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "konrad.schwarz"
  14. subsystem changed to: "80. Thread Package"
  15. title changed to: "Fix Thread Join on WIndows"
  16. type changed to: "Bug"