title: How to properly handle SIGBREAK when closing console?
body: <p>I have to catch the <em>click on close button of console</em> event, which corresponds to ctrl-break event <code>SIGBREAK</code> but apparently there is a kind of timeout which does not allows me to do anything longer than 5 seconds, after what program seems to be aborted (so the message <em>"Properly ended !"</em> will never happend).</p>
  
  <p>How can I force the system to perform closing operations until the end (or to extend the timeout to 60 seconds) ?</p>
  
  <p>Note: with the same method, I can successfully handle CTRL+C event (<code>SIGINT</code>) using <code>fflush(stdout);</code> just before <code>doStuffs();</code></p>
  
  <p>Note 2: my code is based on this answer: <a href="https://stackoverflow.com/a/181594/1529139">https://stackoverflow.com/a/181594/1529139</a></p>
  
  <pre><code>#include &lt;csignal&gt;
  
  void foo(int sig)
  {
      signal(sig, foo); // (reset for next signal)
  
      // do stuffs which takes aboutly 15 seconds
      doStuffs();
  
      cout &lt;&lt; "Properly ended !";
  }
  
  int main(DWORD argc, LPWSTR *argv)
  {
      signal(SIGBREAK, foo);
      myProgramLoop();
  }
  </code></pre>