title: Do Windows apps support SIGINT for user-defined signal handlers?
body: <p>The <a href="https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/signal?view=vs-2019#remarks" rel="nofollow noreferrer">specs</a> say:</p>
  <blockquote>
  <p>SIGINT is not supported for any Win32 application. When a CTRL+C interrupt occurs, Win32 operating systems generate a new thread to specifically handle that interrupt. This can cause a single-thread application, such as one in UNIX, to become multithreaded and cause unexpected behavior.</p>
  </blockquote>
  <p>I think it means by default, the <code>SIG_DFL</code> handler for <code>SIGINT</code> will create a new thread, handle the signal then terminate the program. I'd like to know, does Windows support user-defined <code>SIGINT</code> handler, or will the handler ignored by the OS and the default <code>SIG_DFL</code> handler will run if a CTRL+C interrupt occurs?</p>
  <p>For example, will the following code print <code>Signaled!</code>?</p>
  <pre><code>#include &lt;signal.h&gt;
  #include &lt;stdio.h&gt;
  
  volatile sig_atomic_t signaled = 0;
  void signal_handler(int) { signaled = 1; }
  
  int main() {
      signal(SIGINT, signal_handler);
      while (!signaled) {}
      printf(&quot;Signaled!\n&quot;);
  }
  </code></pre>