Zombie process question

Hey guys,

So i did some research on the site but previous posts answered most of my questions about zombie processes but I have one question that didnt seem to get addressed

"how do you find the parent or parent ID of a zombie process so you can kill it?"

I know p -kill doesnt always just work on the zombie process so how would you find the associated parent so you can just kill the parent process and all associated zombie processes?

---------- Post updated at 07:33 PM ---------- Previous update was at 05:52 PM ----------

Nevermind, I found the answer

Heres how you would find the parent associated with the zombie

1.Do ps-aux first and look for the letter "z" in the stat column

  1. Obtain the PID of the zombie

  2. Do this command to find the parent ID that relates to the zombie and then kill it:
    # ps aux -eo ppid| grep <Zombie Process ID>
    # kill -9 <PPID>

Thanks for researching your own question and posting the answer.

ps -eo state= | grep Z

will also help to find zombie process

This argument seems to be flawed. A Zombie process is already dead. Most versions of unix will clean them up automatically. A "kill" command will have no effect on a Zombie process. If the Zombie process is hung up on I/O it may take a reboot to get rid of that process in which case you may see the error message "some processes refuse to die".

Zombies are already dead but they will not go away until the parent issues a wait call for them. Killing the parent works because init will inherit the zombie and issue that wait call. A process that is hung up on I/O is not a zombie.

True. But a Zombie process which is also hung on I/O may never go away without a reboot. I have seen this with failed hardware monitoring software.

Anybody got an example to post?

It is important that we do not confuse Orphan processes (where the parent has failed) with a Zombie processes.

Finding Zombie processes depends on what version of "ps" your have.
For example:

Berkeley
ps -eo state,pid,ppid|grep \^Z
Unix SV
ps -ef|grep "defunct"

This piece of code is crude and dangerous (and it doesn't work):

Use the "ps -p" switch to look up the parent process ID.

ps -p<PID> -oppid

Then look carefully at the process before considering killing the process using the correct kill signal for that process (which is unlikely to be "-9"). Also do not kill init (PID 1).

One way to cause Zombie processes and other horrors is indiscriminate use of "kill -9".

No such thing. A Zombie has completed execution of the exit system call. Zombies are not hung on I/O. A process can be hung on I/O and it may indeed require a reboot to fix. But that process was no Zombie.