What is a Zombie process in Linux?

You may come across a message that states, “There is 1 zombie process.”.

You might come across this when logging into your Ubuntu Server via SSH. If you see such a message, you don’t have to panic or worry; it is just notifying you. I will explain in depth what this means.

Zombie explained.

On Linux and Unix-based operating systems, a zombie is a process that has completed execution but still has an entry in the process table, allowing the process that started it to read its exit status. In simple words, the child process has died but has not yet been reaped.

When a process ends, all the memory and resources associated with it are deallocated so other processes can use them. However, the process’s entry in the process table remains. The parent is sent a SIGCHLD signal indicating that a child has died; the handler for this signal will typically execute the wait system call, which reads the exit status and removes the zombie.

It can be helpful in some situations; for example, if the parent creates another child process, it will ensure that it will not be allocated the same process ID. The process ID can be reused if a zombie process is stopped or killed. However, if a parent ignores the SIGCHLD, the zombie will be left in the process table.

Finding the zombie processes.

To find the process enter the command below. This command will print the zombie process and display its process ID.

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

To kill it, enter the command below, and replace the <ID> with the process ID displayed in your Terminal.

sudo kill -9 <ID>Code language: HTML, XML (xml)

That’s it, folks; now you have killed a zombie 🙁

Thank you for reading.