zombie process

Hi
What is the command to find only the zombie processes??
How to write the code in C to fetch the no. of zombie processes??

Thanx

Hi,

Use Normal ps command.

# ps aux | awk '{ print $8 " " $2 }' | grep -w Z

Z 4104
Z 5320
Z 2945

To kill a zombie

# kill -9 4104

Sometimes zombie cannot be killed so the solution is to kill the parent process.

The use of grep to post-process awk output is kind-of aberrant; just use awk to figure out which lines have a Z.

ps aux | awk '$8=="Z" { print $2 }'

ps output is somewhat platform-dependent (this seems to work on Linux at least, but might need tweaks for other architectures), and obtaining this information from the kernel on the C level doubly so. On Linux, the proc pseudo-filesystem provides this information. See the proc(5) manual page.

thanx a lot..

ther is no zombie process currently present in my system. is it possible to create a zombie process?? so that i can see the output.

In C, have the parent process fork and exec a child process. And then make the parent exit without waiting on the child. This will result in the child process becoming a zombie.

thanq sooo much... :slight_smile: