title: What happens if you call exit(0) while other threads are still running?
body: <p>Suppose a program has several threads: t1, t2, etc. These are using pthreads. The t2 thread is sitting in a loop reading from a stream and accessing a variable with static storage duration. </p>
  
  <p>Now suppose t1 calls <code>exit(0)</code>.</p>
  
  <p><em>(Further details: I have a program doing this on a Unix-based system, and is compiled with g++. The program appears to occasionally be crashing on shutdown with a stack trace that indicates the static variable is not valid.)</em></p>
  
  <ul>
  <li><p>Does the thread get killed prior to the C++ object destruction?  </p></li>
  <li><p>Is C++ not aware of the threads, so these keep running until the C++ cleanup is complete?</p></li>
  <li><p>Should the <code>SIGTERM</code> handler first shutdown or kill the threads before proceeding, or does this happen automatically?</p></li>
  </ul>