Can't cleanup a zombie process whose parent is init

13.6k views Asked by At

I have a zombie process:

$ ps aux | grep Zl
root      6641  122  0.0  0 0 ? Zl   08:57 371:10 [ovs_dpdk] <defunct>

And, its parent looks like init

$ pstree
init─┬─acpid
     ├─atd
     ├─cron
     ├─dbus-daemon
     ├─dnsmasq
     ├─6*[getty]
     ├─irqbalance
     ├─libvirtd───10*[{libvirtd}]
     ├─ovs_dpdk───{ovs_dpdk}               <==== here
     ├─rpc.idmapd

But, kill -9 does not kill him...

sudo kill -9 6641

I'm stumped here, any help?

4

There are 4 answers

2
khoxsey On

You cannot kill a zombie because it is already dead. :-)

Seriously, a zombie process has already exited, so there is nothing to kill. Its entry in the process table is hanging around until the parent that created the (now dead) child sees the exit status.

Wikipedia (who else?) has a great discussion of this.

You can remove the process entry with SIGCHLD by telling its parent to reap the dead child:

kill -s SIGCHLD PPID

where PPID is the parent process ID. ht the xmodulo folks

1
9mjb On

A zombie is a process that has exited and is no longer running, but stays in the process table till it's parent "wait()s" for it.. to get it's exit status. Kill the parent, or get it to wait on it's child.

1
Tharanga Abeyseela On

How do I kill zombie process?

You cannot kill zombies, as they are already dead. But if you have too many zombies then kill parent process or restart service.

You can kill zombie process using PID obtained from any one of the above command. For example kill zombie proces having PID 4104: kill -9 4104

reference - http://www.cyberciti.biz/tips/killing-zombie-process.html

2
StormChanger On

Zombie can't be clean up by Kill command. If it's a child process of Init process (pid = 1) then it should auto cleanup.

OR As init process is not cleaning up Just Reboot System.

if the Zombies got generated again then might be code bug. You need to look into code issue : as Parent is not waiting for getting the return exit code by child.

As a reference various example is quoted here Generation and cleanup of Zombies n C might be helpful.