title: sending signals to child processes , SIGCONT ,SIGSTOP
body: <p>I have a problem with my code,</p>
  <p>I want all the children stop when the program start.
  and after that I want just the child with the  index of <code>i</code> to continue executing and others to be stopped .</p>
  <h5>I want to execute them in this order p0 ,p1,p2,p3,p4,p0,p1....</h5>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;sys/wait.h&gt;
  
  #define N 5
  
  void handler(int i)
  {
      if (i == SIGCONT)
      {
          printf(&quot;signal cont\n&quot;);
      }
  }
  int main()
  {
      int pid[N];
      for (int i = 0; i &lt; N; i++)
      {
          if ((pid[i] = fork()) == 0)
          {
              /* code */
              while (1)
              {
                  printf(&quot;ici fils %d\n&quot;, i);
                  usleep(50000);
              }
          }
          else
          {
              kill(pid[i], SIGSTOP);
              // kill(pid[i], SIGSTOP);
              if (i == N - 1)
              {
                  kill(pid[i], SIGCONT);
                  sleep(2);
                  kill(pid[i], SIGSTOP);
                  kill(pid[0], SIGCONT);
              }
              else
              {
  
                  kill(pid[i], SIGCONT);
                  sleep(2);
                  kill(pid[i], SIGSTOP);
                  kill(pid[i + 1], SIGCONT);
              }
              // kill(pid[i], SIGKILL);
              waitpid(pid[i], NULL, 0);
          }
      signal(SIGCONT, &amp;handler);
      }
  }
  
  </code></pre>