title: How to use Fork() to create only 2 child processes?
body: <p>I'm starting to learn some C and while studying the fork, wait functions I got to a unexpected output. At least for me. </p>
  
  <p>Is there any way to create only 2 child processes from the parent? </p>
  
  <p>Here my code:</p>
  
  <pre><code>#include &lt;sys/types.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/wait.h&gt;
  
  int main ()
  {
      /* Create the pipe */
      int fd [2];
      pipe(fd);
  
      pid_t pid;
      pid_t pidb;
  
  
      pid = fork ();
      pidb = fork ();
  
      if (pid &lt; 0)
      {
          printf ("Fork Failed\n");
          return -1;
      }
      else if (pid == 0)
      {
          //printf("I'm the child\n");
      }
      else 
      {
          //printf("I'm the parent\n");
      }
  
      printf("I'm pid %d\n",getpid());
  
      return 0;
  }
  </code></pre>
  
  <p>And Here is my output:</p>
  
  <pre><code>I'm pid 6763
  I'm pid 6765
  I'm pid 6764
  I'm pid 6766
  </code></pre>
  
  <p>Please, ignore the pipe part, I haven't gotten that far yet. I'm just trying to create only 2 child processes so I expect 3 "I'm pid ..." outputs only 1 for the parent which I will make wait and 2 child processes that will communicate through a pipe.</p>
  
  <p>Let me know if you see where my error is.</p>