title: Fork and multiprocessing
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;unistd.h&gt;
  int main() {
      int p;
      p = fork();
      if (fork()==0) {
          if (execl("/bin/echo", "/bin/echo", "foo", 0) == -1) {
              fork();
          }
          printf("bar\n");
      }
      else {
          if (p!=0) execl("/bin/echo", "/bin/echo", "baz", 0);
          }
  }
  </code></pre>
  
  <p>Why does this program print baz foo foo and not bar foo baz? At p=fork() a child i created.The parent goes to else{} and prints baz. Then in the line if(fork()==0) a grandchild is created. So the grandchild enters and print foo. Should it also print bar?</p>