title: Simple Signals - C programming and alarm function
body: <pre><code>#include  &lt;stdio.h&gt;
  #include  &lt;signal.h&gt;
  
  
  void  ALARMhandler(int sig)
  {
    signal(SIGALRM, SIG_IGN);          /* ignore this signal       */
    printf("Hello");
    signal(SIGALRM, ALARMhandler);     /* reinstall the handler    */
  }
  
  int main(int argc, char *argv[])
  {
    alarm(2);                     /* set alarm clock          */
    while (1)
      ;
    printf("All done");
  }
  </code></pre>
  
  <p>I expect the program to print "hello" after 2 seconds, but instead the output is "zsh: alarm      ./a.out"</p>
  
  <p>Any idea what is going on?</p>