I launched my program in the foreground (a daemon program), and then I killed it with kill -9
, but I get a zombie remaining and I m not able to kill it with kill -9
. How to kill a zombie process?
If the zombie is a dead process (already killed), how I remove it from the output of ps aux
?
root@OpenWrt:~# anyprogramd &
root@OpenWrt:~# ps aux | grep anyprogram
1163 root 2552 S anyprogramd
1167 root 2552 S anyprogramd
1169 root 2552 S anyprogramd
1170 root 2552 S anyprogramd
10101 root 944 S grep anyprogram
root@OpenWrt:~# pidof anyprogramd
1170 1169 1167 1163
root@OpenWrt:~# kill -9 1170 1169 1167 1163
root@OpenWrt:~# ps aux |grep anyprogram
1163 root 0 Z [cwmpd]
root@OpenWrt:~# kill -9 1163
root@OpenWrt:~# ps aux |grep anyprogram
1163 root 0 Z [cwmpd]
You can clean up a zombie process by killing its parent process with the following command:
I tried
and it works for me.
I tried:
this will work :)
A zombie is already dead, so you cannot kill it. To clean up a zombie, it must be waited on by its parent, so killing the parent should work to eliminate the zombie. (After the parent dies, the zombie will be inherited by pid 1, which will wait on it and clear its entry in the process table.) If your daemon is spawning children that become zombies, you have a bug. Your daemon should notice when its children die and
wait
on them to determine their exit status.An example of how you might send a signal to every process that is the parent of a zombie (note that this is extremely crude and might kill processes that you do not intend. I do not recommend using this sort of sledge hammer):
Found it at http://www.linuxquestions.org/questions/suse-novell-60/howto-kill-defunct-processes-574612/
2) Here a great tip from another user (Thxs Bill Dandreta): Sometimes
will not kill a process. Run
the 4rd field is the parent process, kill all of a zombie's parents and the zombie dies!
Example
18581
,18582
,18583
are zombies -has no effect.
removes the zombies.