Zombie process


For homonymous articles, see Zombie.

In computer science, under UNIX and similar systems, zombie (rather English spelling) is a term for a process that has ended but still has a process identifier (PID) and therefore remains visible in the process table. We also talk about the deceased process.

At the end of a process, the system deallocates the resources that the process still has but does not destroy its control block. The system then passes the process state to the TASK_ZOMBIE value (usually represented by a Z in the "status" column when listing processes with the ps command). The signal SIGCHLD is then sent to the parent process of the process that has ended, to inform it of this change. As soon as the parent process has obtained the completion code of the completed process using the wait or waitpid system calls, the completed process is permanently removed from the process table.

There is a typical bug in UNIX program development that handles multiple processes: a process that creates threads, but does not take care of acquiring their end code. These threads thus remain in the form of zombies during (at least) the entire execution time of the father process. Since zombie processes can not be removed by traditional methods (including privileged users), the system becomes cluttered with processes that are complete ("dead") but still visible. They consume, strictly speaking, no more system resources than the few bytes of memory occupied by the control block in the process table; however, as the number of processes is limited by the possible number of PIDs, too many zombies can prevent the system from creating new processes. This horde metaphor of dead processes, impossible to kill because already dead, is at the origin of the term "zombie".

The only way to eliminate these zombie processes is to cause the death of the parent process, for example by means of the SIGKILL signal. The child processes are then automatically attached to process # 1, usually init, which loads instead of the original parent to call wait on them. If this is not the case, it means that init is failing (or that process # 1 is not init, but another program was not planned for that); the only way to get rid of zombies, in this case, is rebooting the system. code

wiki