LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Unable to kill <defunct> (https://www.linuxquestions.org/questions/linux-general-1/unable-to-kill-defunct-583372/)

Harlin 09-09-2007 08:28 AM

Unable to kill <defunct>
 
Hi All,

When I run 'ps -e | grep defunct' I get this:

[root@stk-srv01 scripts]# ps -e | grep defunct
1659 ? 00:00:00 sh <defunct>
14071 ? 00:00:00 sh <defunct>
28954 ? 00:00:00 sh <defunct>


I tried to run 'kill -9 [pid#]' and they dont go away. Is there any way to get rid of these processes?

Thanks,

Harlin

osor 09-09-2007 12:20 PM

These zombie processes are for most intents and purposes “finished” execution. The only reason one may still be in the process table is that the parent has not yet wait()ed for it. This usually means the parent has a bug or is in an exceptional state. The only way to kill the zombie process is to kill its parent.

Harlin 09-09-2007 12:55 PM

Is there a quick way to find the parent?

Thanks,

Harlin

Tinkster 09-09-2007 01:15 PM

ps -ef
gives the parent (PPID). But you'll find that those things
are often orphaned as well, and hence owned by init ...
*DON'T* kill process #1 in an attempt to get rid of them ;}


Cheers,
Tink

Harlin 09-09-2007 02:58 PM

Fair enough. Thanks for the help though.

Harlin

b0uncer 09-09-2007 03:06 PM

Quote:

*DON'T* kill process #1 in an attempt to get rid of them ;}
I think it shouldn't even be possible. There's no sane reason to kill init (any such reason leads to resetting or running shutdown anyway)..

pstree is also a handy tool, try it out - shows processes in a treeview.

cconstantine 09-10-2007 10:19 AM

tiny clarificationn on "wait()" behaviour...
 
Quote:

Originally Posted by osor (Post 2886654)
The only reason they are still in the process table is that the parent is wait()ing for it.

I'm not knitpicking; just want to make sure the original poster has it clear...

the zombie proc is laying around because the parent has NOT yet called the wait() system call to syncronize it's execution with the child.

When the parent calls wait(), the child process -- really, one of it's children if it has more than one zombie -- will be cleaned up. Of course, if the parent is buggy, or poorly written, it'll never actually call wait() and you have zombies until you kill the parent (as someone else already pointed out.)

-c

Harlin 09-10-2007 11:06 AM

No worries... I don't plan on doing an init kill anytime soon. ;-)


All times are GMT -5. The time now is 04:19 PM.