title: How can I make a "binary process tree"?
body: <p>I have a number of process to create. Every son has to create two sons. I used a recursive solution, it works but the number of process created aren't what I want.</p>
  
  <p>This is what I tried:</p>
  
  <pre><code>void generate_kid(int g, int res){
    pid_t kid1, kid2;
    int status1, status2;
    if( res &gt; 0 ){
      if( kid1 = fork() ){
        if( res &gt; 0){
          if( kid2 = fork() ){
          }
          else {
            printf("I am %d, my father is %d\n",getpid(),getppid());
            generate_kid(g,res/2-1);
          }
        }
      }
      else {
        printf("I am %d, my father is %d\n",getpid(),getppid());
        generate_kid(g,res/2-1);
      }
    }
    waitpid(kid1,&amp;status1,0);
    waitpid(kid2,&amp;status2,0);
  }
  </code></pre>