title: How to handle SIGHLD
body: <p>I'm having some troubles using sigchld...</p>
  
  <p>what I want to do is to create a child process with fork and make the child print and sleep a second for a couple of times... during these process I want to send signal to child (SIGSTOP and SIGCONTINUED) and I want the parent to print what the signal was... here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/wait.h&gt;
  #include &lt;sys/types.h&gt;
  void handler (int i) {
      int x;
      waitpid(-1,&amp;x, 0);
      printf("WIFSTOPPED=%d, WIFCONTINUED=%d\n", WIFSTOPPED(x),WIFCONTINUED(x) );
  }
  
  int main(){
  
      int x;
      int q=fork();
      if(q==0){
          int i=0;
          printf("%d\n",getpid());
          while (i&lt;20){
              printf("%d\n", i++);
              sleep(1);
          }
          _exit(0);
      }
      else {
          signal(SIGCHLD, handler);
          waitpid(-1,&amp;x, 0);
          while(WIFEXITED(x)!=1){
              waitpid(-1,&amp;x, 0);
              sleep(1);
          }
          exit(0);
      }
  }
  </code></pre>
  
  <p>but it doesn't work beacause when I send a SIGSTOP or SIGCONTINUED to the child, the child stop and continue but the parent doesn't print anything</p>
  
  <p>any suggestion?</p>