Monday, November 2, 2009

Killing disgusting zombie processes

I had a dead rsync that refused to die even with kill -9. After some google research, I found that 'ps -l' can show parent process of a zombie.

First some background; A zombie is basically a dead process, and they reason they exist is so that the parent process can retrieve the zombie's exit status and such. If you kill the parent process, the zombie will become a child process of PID 1 (init), and init is always waiting for children to die, so that they don't remain zombies. Note, zombies consumes almost no resources.

# ps ax |grep rsync
4337 pts/3 Z 0:00 [rsync]
# kill -9 4337
# ps ax |grep rsync
4337 pts/3 Z 0:00 [rsync]
# ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 0 2678 2654 0 75 0 - 1016 wait pts/3 00:00:00 bash
0 T 0 4335 2678 0 75 0 - 904 finish pts/3 00:00:00 nfs2local.sh
0 Z 0 4337 4335 0 75 0 - 0 exit pts/3 00:00:00 rsync

# kill 4335
# ps ax |grep rsync
#

Voila!