title: Where do Zombie processes go after their parent dies?
body: <p>A Zombie process is a process that has completed execution, but still has an entry in the process table (the parent hasn't read its exit code, or in other words, it hasn't been "reaped").  </p>
  
  <p>An Orphan process is a process whose parent has finished, though it remains running itself (its parent has "passed away" but it is still "alive"). in this case, <code>init</code> will adopt it and will wait for it.</p>
  
  <p>So consider this:  </p>
  
  <pre><code>int main(int argv, char *argc[]) {
  
      pid_t p=fork();
  
      if (p&lt;0) {
          perror("fork");
      }
  
      // child
      if (p==0) {
          exit(2);
      }
  
      // parent sleeps for 2 seconds
      sleep(2);
      return 1;
  }
  </code></pre>
  
  <p>The child process being created here will be a zombie for 2 seconds, but what will be its status when the parent finishes? Orphan-zombie?  </p>
  
  <p>What happens to its entry in the process table?  </p>
  
  <p>Are "orphan-zombies" (such as the above) also adopted by <code>init</code> and being reaped by it?</p>