How to Kill Zombie Process

Dear Bos,

I have one server,everday if I check with command TOP always present zombie,like below:

last pid:  4578;  load averages:  0.15,  0.11,  0.13                                                                                                07:56:15
298 processes: 295 sleeping, 1 running, 2 zombie, 1 on cpu
CPU states:     % idle,     % user,     % kernel,     % iowait,     % swap
Memory: 8192M real, 2465M free, 7700M swap in use, 2541M swap free

how to kill zombie process?thank for your help.

warm regards

Fredginting

Technically you cannot kill zombies - they are already dead.

Either reboot the system, kill the parent process or restart the particular service.

check out preap. this does not always work. may need to try and kill -9 it.

You can let try..

for i in `ps -lLef | grep defunct |grep -v grep | awk '{print $4}'`
               do 
                 echo "Killiing Process..pidno= $i" ; sleep 1 
                  kill -9 $i ; sleep 5; 
               done

This is pointless. A defunct process as its names implies is dead. Being dead, it cannot be killed "more", even with "-9". Also, a dead process uses no resources (RAM, CPU, I/O ...) so isn't really an issue per se , unless there are thousands or more, by polluting ps output and filling the process table.
The fact there are defunct processes is however exhibiting a bug or anomaly with their parent processes.

1 Like

I'm curious what the zombie is, or was.

Hi jlliagre
fredginting wants to kill zombie process.I show the way of how do it just probably..
Zombie process already inactive but it remains to stay in ps table..
In this way parent can read exit status of its chid process(so zombie process)..
Zombie process has not been waited for its parent process..
Maybe if it waits to its parent process then parent process send wait() call to system for its zombie and system is kill the its zombie..
on this state kill -9 does not guarantee to kill a zombie process never.
If completely kill it firstly kill the parent process which has the zombie process..
In my opinion zombie can stay here baceuse has any damage to me :smiley:

thanks for sharing your informations :slight_smile:

Many of you are not understanding. jlliagre is correct but not getting through somehow.

A zombie process merely clogs up a process slot in the kernel process entry table. It has no resources tied up. It is waiting to return status to a parent (called reaping), and the parent has not called wait(). Some negligent parents never call wait.

If a parent exits before calling wait then the init process reaps the orphaned child process. It may spend a short while as a zombie.

[opinion]

I personally think the guy who created the idea of calling those processes a 'zombie' was creative and totally misguided. We all know that somehow zombies are evil. Therefore you have to get rid of them They must be vermin. Kill them all!

This is a case of the name providing non-existent negative attributes to something.
Zombies are okay. They are not as evil as the name implies.

[/opinion]

What you really need to do: fix the bad programming that creates them. Or hire good programmers.

Zombies DO NOT respond to signals because they lack the process context to do so.
Kill -9 sends a signal.

Commands like preap just remove them from the internal kernel table by forcing the naughty parent process to call wait. Plus, it is OKAY to have a few zombies. It gives some programmers a chance to worry about something harmless, and bug the sysadmin.
Sysadmins love to be bugged by users.

When you have loads of zombies and they persist for days, it is time to rewrite code, or spend all day calling preap (on Solaris).

2 Likes

I am employed, with a mortgage...and an endless commute...another form of zombie. Not necessarily evil...but unable to respond to signals in many, many ways. (Just ask the wife if my ears work...)

Very good explanation, jim_mcnamara. Perhaps we've met another form of the useless use of cat? Killing the dead?

Good article thanks.But I dont say to jlliagre is not correct ?

Not sure what means I'm not getting through. As I wrote, two zombies processes isn't a problem. They won't hurt the process table which has 32000 entries on Solaris and can be raised up to 999999. The only issue is cosmetic. I.e. zombies pollute ps and similar commands output. Reaping can fix that but the real issue is parent processes not handling their child's death, as I wrote too.