howto kill defunct processes
Hello all here in the message boards..
Would anyone know the best procedure for killing "defunct" processes? I tried killing some but they reappear. I'm not sure how to locate their parent process and stop the "defunct" pid's from coming back. |
use "kill -9 PID" instead of "kill PID"
|
i understand that, but how do identify which process is the parent process, sometimes it's not clear
|
A process can't "come back". What happens is either 1) the process never really died, or 2) the parent process is intentionally monitoring it's children and actively spawning another process when the first one got killed. I suspect number one, as programs can handle a term signal without terminating. If it is number two, then the processes are very likely not defunct, as they are respawning other processes.
|
You cannot kill a defunct process (a.k.a zombie) as it is already dead.
It doesn't take any resources so it's no big deal but if you really want it to disappear form the process table you need to have its parent procees reaping it. "pstree" should give you the process hierarchy and "kill -1 <parent-pid>" is sometimes enough for the job. |
Quote:
1. If you want to kill a process first find out the pid. For example I want to kill "mythfrontend" process tdec@amd:~> ps -C mythfrontend PID TTY TIME CMD 11063 ? 00:01:05 mythfrontend tdec@amd:~> kill -9 11063 2. Here a great tip from another user (Thxs Bill Dandreta): Sometimes kill -9 <pid> will not kill a process. Run ps -xal the 4rd field is the parent process, kill all of a zombie's parents and the zombie dies! Example 4 0 18581 31706 17 0 2664 1236 wait S ? 0:00 sh -c /usr/bin/gcc -fomit-frame-pointer -O -mfpmat 4 0 18582 18581 17 0 2064 828 wait S ? 0:00 /usr/i686-pc-linux-gnu/gcc-bin/3.3.6/gcc -fomit-fr 4 0 18583 18582 21 0 6684 3100 - R ? 0:00 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/cc1 -quie 18581,18582,18583 are zombies - kill -9 18581 18582 18583 has no effect. kill -9 31706 removes the zombies. Ciao -=terry(Denver)=- |
Quote:
First figure out what the 31706 process is, and exercice judgment. For example if it is an application you are currently running, try exiting it using its interface. If it is a service currently used by other people, it may be unwise to abruptly shutting it down. In any case, try less extreme options before "kill -9". eg: Code:
kill -1 31706 Use "kill -9" only if the zombies are still there. |
All times are GMT -5. The time now is 01:54 PM. |