Penguin
Blame: ZombieProcess
EditPageHistoryDiffInfoLikePages
Annotated edit history of ZombieProcess version 5, including all changes. View license author blame.
Rev Author # Line
1 JohnMcPherson 1 In unix-like operating systems, ALL processes (apart from the first one) are created by other processes. To create a new process, a current process does a fork(2) system call.
2 The kernel then creates the internal structures needed in the process table. Often, the parent process does a wait4(2) system call, which means it waits for the child process to finish. This means you can get a little info about the process after it finished, like cpu time, etc.
3
3 CraigBox 4 If you don't care when the process finishes, you have to explicitly say so, otherwise the kernel will keep the info in the process table expecting your process to eventually call wait4(2) or a similar function. A process that has finished (and so is using no memory) but has not yet been "reaped" is called a Zombie, and the kernel is keeping its process table entry alive.
4 JohnMcPherson 5
6 Two ways to avoid creating Zombies (other than calling one of the wait() functions) include:
7 # handling the [SIGCHLD] signal (see that page for example code)
8 # fork(2) and then get the child to fork(2) again and then exit immediately, so that you've created a grandchild rather than a child.
5 AlastairPorter 9
10 Zombie processes will show 'Z' in the __STAT__ column of ps -aux