Welcome to my site. Please CLICK HERE to give your opinions regarding this new look of "PCTipsbyAnu". Thanks for visiting.

Monday, February 7, 2011

Browse » Home » , , , » How To Find And Kill Zombie Process On Linux System?

How To Find And Kill Zombie Process On Linux System?



A zombie process (a.k.a. defunct process) is a process that has endedexecution but left in the process table of Linux operating system. So,how to handle or terminate zombie process on Linux system?



Suppose the parent process that started it has executed wait system callto read its child process exit status, there will be no such defunctprocess left in the process table.

As the process terminated, the memory or system resources usedduring its execution are freed or released to operating system.Therefore, zombie process consumes very little system resource, exceptwhen the number of defunct process increases tremendously untiloverload process table.

How to find out or check the number of zombie process on Linuxsystem? The following commands can help (reference is based on RedhatLinux, RHEL 5 to be precise).

To check zombie / defunct process existence:

ps -elf | awk '{print $2" "$4" "$5}' | grep ^Z

where the output of first column indicates status of process,second column denotes process ID (PID) and third column is parentprocess ID (PPID).

Alternative, grep the “defunct” keyword, i.e.:

ps -elf | grep defunct

To find out the number of these defunct processes (assuming theprevious command returns a long list), simply include “wc” command.E.g. either one of these two commands will do:

ps -elf | awk '{print $2}' | grep ^Z | wc -l
ps -elf | grep defunct |grep -v grep | wc -l
How to terminate zombie / defunct Linux process?

Remember the definition of zombie process? It is a process that hasstopped execution except its entry in process table of Linux operatingsystem (and thus consuming little system resources, if the number ofsuch process is small).

Therefore, you hardly can terminate defunct process by using “kill -9″ command. You might able to remove the zombie process by:

  1. Restart or terminate its parent process that spawn it.
  2. Manually sending SIGCHLD signal to parent process (advised by expert by never work for my cases):
    kill -s SIGCHLD ppid

    where ppid is the parent process ID of the defunct process.
  3. Reboot the Linux system, if the number of zombie process grows upto a harmful level (i.e. causes system performance and reliability todegrade).

If possible, talk to programmers who develop the parent process andfind out from them is that designed by purpose (e.g. to avoid new childprocess reuse process ID taken by terminated child process and thusbecomes defunct) or it is actually a bug that can be fixed.
You can leave a response, or trackback from your own site.

About 'Anu': My name is 'Anu' also Known as 'ANU 007 TIGER' .I'm administrator of 'PC Tips by Anu' blog .This blog was opened for sharing contents about hacking n cracking.
Thanks YAHOO OR GMAIL

0 comments:

Post a Comment

 
Back to Top