title: C: wait for a signal
body: <p>I have a problem with this code..</p>
  
  <p>I need to put in wait (<code>sigwait</code>) a process until arrive almost one of those Signals <code>SIGUSR1</code>/<code>SIGUSR2</code> (maybe I can use <code>sigalrm</code> to catch the signals?) </p>
  
  <pre><code>#include &lt;signal.h&gt;
  #include &lt;stdio.h&gt;
  
  int main()
  {
      sigset_t set;
      int sig;
  
      sigemptyset(&amp;set);
      sigaddset(&amp;set, SIGUSR1);
      sigaddset(&amp;set, SIGUSR2);
      sigprocmask(SIG_BLOCK, &amp;set, NULL);
      sigwait(&amp;set, &amp;sig);
      printf("Got signal %d\n", sig);
      /*need to set Sigalrm?*/
      return 0;
  }
  </code></pre>