title: Signal Handler for SIGINT
body: <p>I'm supposed to write a C program which handles the first SIGINT with a custom handler, and then reset the default behaviour. My custom SIGINT handler should just print a msg. This is what I wrote:</p>
  
  <pre><code>#include &lt;string.h&gt;
  #include &lt;strdio.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;signal.h&gt;
  
  void handler(sig)
  int sig;
  {
      printf("%d received\n",sig);
  }
  
  int main(){
      signal(SIGINT, handler);
      signal(SIGINT, SIG_DFL);
      while(1);
      exit(0);
  }
  </code></pre>
  
  <p>If I launch it from a shell and then I enter <kbd>Ctrl</kbd>+<kbd>C</kbd> on the same tab, it works. If I try to send the SIGINT using <code>kill -INT *process pid*</code> it just terminates the program, no msg printed. Any idea why?</p>