title: sigsuspend() does not react against signal
body: <p>My target is to intercommunicate main process and its "fork" children.
  Communication is done by signal delivery.</p>
  
  <p>My problem appears when first child gets stuck waiting when waiting for SIGUSR1 signal.</p>
  
  <p>I have no real idea why it gets stuck on that point. Evenmore if I sent signals by console, that child process seems not paying attention.</p>
  
  <p>Could anybody help me?</p>
  
  <hr>
  
  <p>Here comes the code</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;signal.h&gt;
  
  int N = 5;
  int _pipe[2];
  pid_t children[5];
  
  void main(){
      pid_t parent_pid;
      pid_t pid;
      int i = 0;
  
      sigset_t set;
      sigfillset(&amp;set);
  
      parent_pid = getpid();
      fprintf(stderr,"I am main process, here comes my pid %u\n",getpid());
  
      if (0&gt;pipe(_pipe)) fprintf(stderr,"Error when creating pipe");
  
      //Start creating child processes
      while (i &lt; N){
              pid = fork();
              if (pid == 0){
                  close(_pipe[1]);
              break;
          }
          else{
              fprintf(stderr,"Created child with pid %u\n",pid);
              children[i] = pid;
              write(_pipe[1],&amp;pid,sizeof(pid_t));
          }
          i = i+1;
      }
  
      i = 0;
  
      // What main process does
      if (pid&gt;0){
          close(_pipe[0]);
          close(_pipe[1]);
  
          sigdelset(&amp;set,SIGUSR2);
  
          sigdelset(&amp;set,SIGTERM);
          sigdelset(&amp;set,SIGKILL);
  
          // Main process sends signal to each child
          while(i &lt; N){           
              kill(children[i],SIGUSR1);
              fprintf(stderr,"Sent SIGUSR1 to child %u\n",children[i]);
              // .. Now just wait for SIGUSR2 arrival
              sigsuspend(&amp;set);
  
              i = i+1;
          }
      }
      // What children do
      else{
          // Wait for main process SIGUSR1 delivery
          sigdelset(&amp;set,SIGUSR1);
          sigsuspend(&amp;set);
  
          fprintf(stderr, "SIGUSR1 arrived child %u from its father",getpid());
  
          // Once SIGUSR1 has arrived, pipe is read N times
          while((i &lt; N) &amp;&amp; (read(_pipe[0],&amp;pid,sizeof(pid_t))&gt;0)){
              children[i] = pid;
              i = i+1;
          }
          close(_pipe[0]);
  
          // After reading pipe, a reply is sent to parent process
          kill(parent_pid,SIGUSR2);
      }
  }
  </code></pre>