title: How do you query a pthread to see if it is still running?
body: <p>In my destructor I want to destroy a thread cleanly.</p>
  
  <p>My goal is to wait for a thread to finish executing and THEN destroy the thread.</p>
  
  <p>The only thing I found about querying the state of a pthread is <a href="https://computing.llnl.gov/tutorials/pthreads/man/pthread_attr_getdetachstate.txt" rel="noreferrer">pthread_attr_setdetachstate</a> but this only tells you if your thread is:</p>
  
  <ul>
  <li>PTHREAD_CREATE_DETACHED </li>
  <li>PTHREAD_CREATE_JOINABLE</li>
  </ul>
  
  <p>Both of those have nothing to do with whether the thread is still running or not.</p>
  
  <p><strong>How do you query a pthread to see if it is still running?</strong></p>