title: Trouble sending and handling signals with children processes in C
body: <p>The parent process forks two children, each replace <code>SIGUSR1</code> and <code>SIGUSR2</code> signal respectively. </p>
  
  <p>The parent process replace <code>SIGINT</code> signal, on catching it, send <code>SIGUSR1</code> and <code>SIGUSR2</code> to its children respectively.</p>
  
  <p>The expected output when Ctrl-C is pressed should be:</p>
  
  <pre><code>Ctrl+C is pressed。
  received SIGUSR1 signal
  received SIGUSR2 signal
  </code></pre>
  
  <p>But on Ctrl-C I've got</p>
  
  <pre><code>Ctrl+C is pressed。
  </code></pre>
  
  <p>I have no idea why <code>sig_handler_1</code> and <code>sig_handler_2</code> are not excuted.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/wait.h&gt;
  #include &lt;signal.h&gt;
  void fun_ctrl_c(int);
  void sig_handler_1(int);
  void sig_handler_2(int);
  pid_t pid1;
  pid_t pid2;
  int status;
  
  int main() {
      pid1 = fork();
      if (pid1 == 0) {    // child 1
          // avoid to be killed
          (void) signal(SIGINT, SIG_IGN);
          // replace SIGUSR1
          (void) signal(SIGUSR1, sig_handler_1);
          raise(SIGSTOP);
      } else {
          pid2 = fork();
          if (pid2 == 0) {    // child 2
              // avoid to be killed
              (void) signal(SIGINT, SIG_IGN);
              // replace SIGUSR2
              (void) signal(SIGUSR2, sig_handler_2);
              raise(SIGSTOP);
          } else {    // parent
              (void) signal(SIGINT, fun_ctrl_c);
              waitpid(-1, &amp;status, 0);
          }
      }
      return 0;
  }
  
  void fun_ctrl_c(int)
  {
      printf("Ctrl+C is pressed。\n");
      kill(pid1 ,SIGUSR1);
      kill(pid2 ,SIGUSR2);
      (void) signal(SIGINT, SIG_DFL);
  }
  
  void sig_handler_1(int)
  {
      printf("received SIGUSR1 signal\n");
  }
  
  void sig_handler_2(int)
  {
      printf("received SIGUSR2 signal\n");
  }
  </code></pre>