Should we get rid of the proper process

What is a "zombie process" in Linux?

If you're a Linux user, you may have seen zombie processes on your process list. You cannot end a zombie process because it is already dead - like an actual zombie.

Zombies are basically the remnants of dead processes that have not been properly cleaned up. A program that creates zombie processes is not programmed correctly - programs are not supposed to hang zombie processes.

What is a zombie trial?

To understand what a zombie process is and why zombie processes are showing up, you need to know something about how processes work on Linux.

When a process crashes on Linux, it is not all immediately removed from memory - its process descriptor remains in memory (the process descriptor only takes up a small amount of memory). The status of the process becomes EXIT_ZOMBIE and the parent process is notified that its child process has died with the SIGCHLD signal. The parent process must then issue the wait () system call to read the dead process termination status and other information. This allows the parent process to get information from the dead process. After waiting () is called, the zombie process is completely removed from memory.

This usually happens very quickly, so you won't watch zombie processes pile up on your system. However, if a parent process is improperly programmed and never calls wait (), the child zombies will remain in memory until they are cleaned up.

Utilities like GNOME System Monitor above Command and the ps Command display zombie processes.

Dangers of zombie trials

Zombie processes do not consume any system resources. (In fact, everyone uses a very small amount of system memory to store their process descriptor.) However, each zombie process retains its process identifier (PID). Linux systems have a limited number of process IDs - 32767 by default on 32-bit systems. When zombies accumulate very quickly - for example, when incorrectly programmed server software under load creates zombie processes - the entire pool of available PIDs is eventually assigned to zombie processes so that other processes cannot start.

However, a couple of zombie processes hanging around are not a problem - although they indicate a bug with their parent process on your system.

Get rid of zombie processes

You cannot kill zombie processes because you can kill normal processes with the SIGKILL signal - zombie processes are already dead. Remember that you don't need to get rid of zombie processes until you have a large amount on your system - some zombies are harmless. However, there are a few ways that you can get rid of zombie processes.

One possibility is to send the SIGCHLD signal to the higher-level process. This signal instructs the parent process to execute the wait () system call and clean up the child zombies. Send the signal with the kill Command, replace pid in the following command with the PID of the higher-level process:

kill -s SIGCHLD pid

However, if the higher-level process is not programmed correctly and ignores SIGCHLD signals, this will not help. You need to end or close the parent process of the zombies. When the process that created the zombies finishes, init inherits the zombie processes and becomes their new parent. (init is the first process that is started under Linux when booting and is assigned the PID 1.) init regularly executes the wait () system call to clean up the subordinate zombies, so init keeps the zombies brief. You can restart the parent process after closing it.

If a parent process continues to create zombies, this should be fixed so that wait () is properly called to harvest the child zombies. Submit a bug report if a program continues to create zombies on your system.