title: C wait for signal with loop
body: <p>In C Linux, is there any way to wait for signal like <code>SIGUSR1</code> and <code>SIGUSR2</code> without loop?</p>
  
  <p>For eaxmple in this code I wait for <code>SIGUSR1</code> or <code>SIGUSR2</code> to print message, but while I want , I do while true....</p>
  
  <pre><code>#include &lt;unistd.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;signal.h&gt;
  
  void signal_callback_handler(int signum)
  {
     printf("Caught signal %d\n",signum); 
  }
  
  int main()
  {
     signal(SIGUSR1, signal_callback_handler);
     signal(SIGUSR2, signal_callback_handler);
     while(1)
     {
        printf("Program processing stuff here.\n");
        sleep(1);
     }
     return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>How can I wait and do not do anything (do not do while true)  until <code>SIGUSR1</code> or <code>SIGUSR2</code> arrived ?</p>
  
  <p>For example :</p>
  
  <pre><code>#include &lt;unistd.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;signal.h&gt;
  
  void signal_callback_handler(int signum)
  {
     printf("Caught signal %d\n",signum); 
  }
  
  int main()
  {
     signal(SIGUSR1, signal_callback_handler);
     signal(SIGUSR2, signal_callback_handler);
  
      printf("this line happned after signal arrived \n ");
     return EXIT_SUCCESS;
  }
  </code></pre>