Identify zombie processes and get rid of them
Identify zombies
Identify the parent processes of your zombies
Leave out the last line | grep “: Z” to get parents of all processes
ps ax | awk '{print $1}' | grep -v "PID" \
| xargs -n 1 ps lOp | grep -v "UID" \
| awk '{print"pid: "$3" *** parent_pid: " \
$4" *** status: "$10" *** process: "$13}' \
| grep ": Z"
Kill zombies
To kill a zombie process you need to utilize GDB.
GDB itself expects an ‘call wait()’ command per PID
If there are many zombie in your process list it’s lot of typing
So, lets get all the zombie PIDs and print out a copy&paste ready list of commands to paste into GDBs prompt.
ps aux | grep defunc | grep -v grep | awk '{ print "call wait("$2")" }'
Start gdb binary now, knowing the PID of the mother process
This will connect gdb directly into the running process
# gdb /usr/local/sbin/program [motherPID]
gdb> call wait([zombiePID])
gdb>