Zombie process in Linux
Logging into one of my Linux boxes, I noticed I had a zombie process.
Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-88-generic x86_64)
=> There is 1 zombie process.
A zombie process is
Processes marked are dead processes (so-called "zombies") that remain because their parent has not destroyed them properly. These processes will be destroyed by init(8) if the parent process exits.
A zombie process has a process state code of Z
(how fitting), so we can filter on zombie processes this way:
ps axo stat=,pid= | grep "^Z"
Z 139262
To get just the PID of the zombie process:
ps axo stat=,pid= | grep "^Z" | awk '{ print $2 }'
139262
To find the parent process:
pstree -p -s 139262
systemd(1)---containerd-shim(1896480)---hugo(1896502)---gzip(139262)
And finally, to kill the zombie's parent process:
kill 1896502
References
ps(1) - Linux man page https://linux.die.net/man/1/ps