title: Why zombie processes exist?
body: <p>Wikipedia says "A child process that terminates but is never waited on by its parent becomes a zombie process." I run this program: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;stdlib.h&gt;
  int main()
  {
      pid_t pid, ppid;
      printf("Hello World1\n");
      pid=fork();
      if(pid==0)
      {
          exit(0);    
      }
      else
      {
          while(1)
          {
          printf("I am the parent\n");
          printf("The PID of parent is %d\n",getpid());
          printf("The PID of parent of parent is %d\n",getppid());        
          sleep(2);
          }
      }
  }
  </code></pre>
  
  <p>This creates a zombie process, but I can't understand why a zombie process is created here? </p>
  
  <p>The output of the program is</p>
  
  <pre><code>Hello World1
  I am the parent
  The PID of parent is 3267
  The PID of parent of parent is 2456
  I am the parent
  The PID of parent is 3267
  The PID of parent of parent is 2456
  I am the parent
  ....
  .....
  </code></pre>
  
  <p>But why is it that the "child process terminates but is not waited on by its parent" in this case?</p>