title: How to use sigsuspend
body: <p>I have this code, and i have to make the program block repeatedly waiting for a signal. My teacher wants us to use the sigsuspend and masks instead of pause or sleep. I'm not familiar with the sigsuspend or mask, i know that sigsuspend() temporarily replaces the signal mask of the calling process with the mask given by mask and then suspends the process until delivery of a signal whose action is to invoke a signal handler or to terminate a process.
  But how do I implement it.</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/types.h&gt;
  
  unsigned Conta = 0;
  
  void mypause(int sign)
  {
      switch (sign)
      {
          case SIGINT:
              printf("You've pressed ctrl-C\n");
              printf("I'm running waiting for a signal...\n");
              Conta++;
              break;
  
          case SIGQUIT:
              printf("You've pressd ctrl-\\n");
              printf("Number of times you've pressed CTRL-C: %d", Conta); 
              exit(0);
              break;
      }
  }
  
  int main()
  {
      alarm(3);
      printf("I'm Alive\n");
  
      signal(SIGINT, mypause);
      signal(SIGQUIT, mypause);
      printf("I'm running, waiting for a signal...\n");
      while (1)
      {
      }
  
      return (0);
  }
  </code></pre>