Alternative way to kill a zombie process

You can't kill a Zombie (process), it is already dead. It is just waiting for its parent process to do wait(2) and collect its exit status. It won't take any resource on the system other than a process table entry.

You can send SIGCHLD to its parent to let it know that one of its children has terminated (i.e. request it to collect child's exit status). This signal can be ignored (which is the default):

kill -CHLD <PPID>

(Replace <PPID> with the actual PID of the parent.)

Or you can kill the parent process so that init (PID 1) will inherit the zombie process and reap it properly (it's one of init's main tasks to inherit any orphan and do wait(2) regularly). But killing the parent is not recommended. Generally, creation of zombie processes indicates programming issue/issues, and you should try to fix or report that instead.


As mentioned by Heemayl, you cannot actually kill a zombie. It's already [un]dead...

However, the problem you are facing looks like a problem with the git clone command. It gets stuck somehow. Probably times out or fails in some other way? It is often because of some I/O that a process gets stuck to the point where a SIGTERM and SIGINT won't work.

To kill it, in this case, you want to use the -9 command line option. This means send the SIGKILL signal. You can actually use -KILL too.

[root@host user]# kill -KILL 746 29970

To get a list of available signals, use the list command line option.

[root@host user]# kill -l

This shows you the numbers and names (and you'll see that #9 says SIGKILL.)


to look for zombie processes:

ps aux | grep -w Z | grep -v grep

ps -eo stat,ppid | grep -w Z

to kill zombie process, the parent IDs need to be killed ie PPID:

kill PPID1 PPID2

kill $(ps -eo stat,ppid|grep -w Z|awk '{print $2}'|tr "\n" " ")

Tags:

Process

Kill