Solution to the Linux zombie process that cannot be killed: 1. Use the cat command to view the parent process ID of the zombie process. The syntax is "cat /proc/zombie process's process ID/status"; 2. Use the kill command , just kill the parent process, the syntax is "kill -9 process number of the parent process".
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
You can use the kill command to terminate the process in the Linux system. Despite the name, the kill command and a set of other commands (such as pdill and killall) are written/designed to send certain signals to one or more processes. When not specified, the default signal it sends is the SIGTERM signal that terminates the process.
When the parent process dies or is killed, and its child process does not die with its parent process, we call the process an orphan process.
How to kill zombie processes
On the other hand, zombie processes cannot be killed! If you are asking? Because they are already dead!
After each child process terminates, it will become a zombie process and then be deleted by its parent process. When a process exits its existence and releases the resources it used, its name is still on the OS process table. Its name is then removed from the process table by its parent's process. When it fails, we have a zombie process, but it is no longer a real process, but just an entry on the operating system's process table.
This is why even using the command kill -9 (SIGKILL) on a dead (zombie) process does not work, because there is nothing to kill.
Therefore, to kill a zombie process and remove its name from the process list, you must kill its parent process. For example, if PID 5878 is a zombie process and its parent is PID 4809, to kill the zombie (5878), also end PID 4809:
sudo kill -9 4809 #4809 is the parent, not the zombie
but be very careful when killing the parent process. If the parent of the process is PID 1 and you kill it, the system will be restarted!
Examples are as follows:
1. View the parent process based on the child process
cat /proc/pid/status
2. Use "kill -9 process number of the parent process" to delete the parent process;
Recommended learning: Linux video tutorial
The above is the detailed content of What to do if the Linux zombie process cannot be killed. For more information, please follow other related articles on the PHP Chinese website!