Skip to content

Instantly share code, notes, and snippets.

@ilake
Last active December 16, 2015 12:29
Show Gist options
  • Select an option

  • Save ilake/5434972 to your computer and use it in GitHub Desktop.

Select an option

Save ilake/5434972 to your computer and use it in GitHub Desktop.

Zombie Processes

A Child Process existed but the parent doesn't wait it or detach it.

If you're not going to wait for a child process to exit using Process.wait (or the technique described in the next chapter) then you need to 'detach' that child process.

What does Process.detach do? It simply spawns a new thread whose sole job is to wait for the child process specified by pid to exit. This ensures that the kernel doesn't hang on to any status information we don't need.

  ps -ho pid,state -p [pid of zombie process]

Any dead process whose status hasn't been waited on is a zombie process, So every child process that dies while its parent is still active will be a zombie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment