title: C++ Crash/exception handler in Qt application with thread support on Windows
body: <p>I want to make a crash/exception handler for my Qt application. I have the handler working already (not included in the code below). The problem is on Windows that it only works if the crash occures in the same thread where <code>signal()</code> and <code>std::set_terminate()</code> is called.</p>
  
  <p>On Linux it seems to work for all threads by default.</p>
  
  <p>Is there a way to make it work for all application threads on Windows?</p>
  
  <pre><code>#include "mainwindow.h"
  #include &lt;QApplication&gt;
  #include &lt;stdio.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;exception&gt;
  
  void seg_handler(int sig)
  {
      // Crash/exception handling code
      // ...
      exit(1);
  }
  
  void std_handler( void ) {
       seg_handler(1);
  }
  
  int main(int argc, char *argv[]) {
  
      signal(SIGSEGV, seg_handler);
      std::set_terminate( std_handler );
  
      QApplication a(argc, argv);
      MainWindow w;
      w.show();
  
      return a.exec();
  }
  </code></pre>