title: How to use fork() to create a child process out of a child?
body: <p>I want create a son(1) with fork() and this son needs to create another son(2). </p>
  
  <p>son (1) and father needs to wait for their son's end gives a info. I want all of them to <code>printf</code> their PID.</p>
  
  <p>This is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(){
  
    int pid; //i know thats not good
  
    if((pid = fork ()) == 0) { //this isnt good either
      printf ("SON %d\n",getpid());
  
    } else {
      // sleep(1) not necessary
      printf ("Thats the Father\n");
      printf ("PID of my Son PID %d\n",pid);
    }
  }
  </code></pre>
  
  <p>Found several infos to create multiple children out of 1 father but I don't know, how to create a new child out of a child.</p>