title: Issue with alarm() and SIGALRM in C
body: <p>I am having an issue with SIGALRM that seems to not be triggered. I am using signal() rather than sigaction() for simplicity of code. </p>
  
  <p>The purpose is to have some loop that reads, but after x seconds, re-initialize all the variables before reading again. I use an alarm for that.</p>
  
  <pre><code>volatile sig_atomic_t restartBool;
  
  void    catch_alarm(int sig)
  {
      fprintf(stderr, "ALARM CALLED\n");
      restartBool = 1;
  }
  
  int     main(void)
  {
  
       int n, fd_in = 0;
       char newChar;
  
      signal(SIGALRM, catch_alarm);
  
      while (1) {                     /* main loop */
  
              restartBool = 0;
  
              // Set a timer before we start reading
              alarm(2);
  
              while (restartBool == 0 &amp;&amp; (n = read(fd_in, &amp;newChar, 1)) == 1) {       /* parse input */
                  /* ..... */
              }
              fprintf(stderr, "EXITED THE LOOP");
  
              // Cancel the alarm/timer
              alarm(0);
      }
  }
  </code></pre>
  
  <p>Well the fprintf() statement in the catch_alarm() function is never called, and I am not sure why (I am running on Linux).</p>
  
  <p>Any help would great,</p>
  
  <p>Thank you very much,</p>
  
  <p>Jary</p>