A zombie process is a type of process which is finished but it’s entry still remains in the process table due to lack of communication between child and parent process.

In this how-to, I am going to demonstrate how you can check and kill the zombie process in Debian 10.

Prerequisite

You need to have root privileges and at least one zombie process entry in the processes table.

How to check the zombie process in Debian 10

Through command line

You can get a list of all processes running on your system using the top command as shown below.

List zombie processes on the command line

In order to check for a zombie process on your Debian 10 machine, you need to open up a terminal and execute the following command.

ps axo stat,ppid,pid,comm | grep -w defunct

List zombie processes with ps command

Since we do not have any zombie process running on our machine. Therefore, we will create a dummy zombie process in the next step so that I can kill it. If there was a zombie process running, the command would have returned its PID, etc.

Through GUI

The same can also be done with the help of GUI. Open up a system monitor utility from the dashboard as shown below.

system monitor utility

The tool will show you the list of all processes running on your machine. You can also scroll up and down to see all the processes.

Find zombie processes in system monitor

How to create a dummy zombie process in Debian 10

Open up a text editor and paste the following code. The code has been copied fromĀ https://vitux.com/how-to-create-a-dummy-zombie-process-in-ubuntu/

#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>int main ()
{
pid_t child_pid;child_pid = fork ();
if (child_pid > 0) {
sleep (60);
}
else {
exit (0);
}
return 0;
}

Save the file as zombie.c. The zombie process will run for 60 seconds. However, you can adjust the time in sleep function.

Next, open up a terminal and run the following command to compile this program. This will create an executable objective file.

cc zombie.c -o zombie

Next, run the following command to create a zombie process that will be alive for sixty seconds.

./zombie

Dummy Zombie Process

How to kill a Zombie Process

Through command line

Now we have a zombie process therefore, we can also kill it.

Open up the terminal and execute the following command to know the zombie parent process ID.

ps axo stat,ppid,pid,comm | grep -w defunct

You can see from the following screenshot, the parent process ID is the second entry in command result.

Kill Zombie Process

Issue the following command on the terminal with root privileges and this is going to kill the zombie process.

kill -9 <PPID> (which is 2844 in our case)

If you check the processes using ps command, you won’t notice any zombie or defunct process running on your system.

Through GUI

Again, open up a system monitor utility from the dashboard and list the processes from all users. You will notice a single zombie process running on your machine.

Kill a Zombie process in Debian GUI

Now, right-click the zombie process and click on the ‘kill’ button to kill the process. You will be asked for confirmation. Click ‘Kill Process’ to confirm. You will also be asked for a root user credentials.

I hope this tutorial has helped you a lot in understanding zombie processes.

How to Check and Kill Zombie Processes in Debian 10