1824218 Members
3213 Online
109669 Solutions
New Discussion юеВ

defunct processes

 
SOLVED
Go to solution
David_246
Trusted Contributor

defunct processes

Hi,

We have a tool for oracle that creates many defunct processes when we had a network outage.

Because of that I wrote a simple script that does a "ps -ef | grep defunct | grep -v grep"
Now the funny thing is that you very often get an entry for defunct processes.

Please examin a :

while true
do
ps -ef | grep defunc | grep -v grep
done

Now log in via another terminal to the same server and see the output on your screen. What's happening, why does it seem that a process first gets a status of defunct before it dies ??

Am I the only one, or is this genereic ??

Regs David
@yourservice
11 REPLIES 11
Mark Grant
Honored Contributor

Re: defunct processes

Process are defunt while waiting for the parent to do a wait() or waitpid(). Thet are affectionately referred to as zombies. So, for a short time, all processes that die are defunct but most of the time they get cleaned up by the parent.
Never preceed any demonstration with anything more predictive than "watch this"
Steven E. Protter
Exalted Contributor

Re: defunct processes

I have noticed that when I stop and start certain Oracle applications, logging messages that should be going to a file somewhere go to the screen of that terminal session.

It is probably the fault of the shell script oracle provides for starting and stopping the application. Either that, or my changes caused it.

With regards to defunct processes, that behavior I've not seen. Thats something I'd have to go to the vendor for, because open processes have memory reserved and the resource drain could become substantial.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
John Bolene
Honored Contributor

Re: defunct processes

All processes go thru the defunct or zombie stage while they are terminating and being cleaned up by the operating system.

It is possible to catch a few of them if you have them constantly happening, but it is a very short time that they normally spend in this state.

Abnormally, they will stay in this state and be permannent zombies if they cannot communicate with their parent and the parent has requested that they do this.
It is always a good day when you are launching rockets! http://tripolioklahoma.org, Mostly Missiles http://mostlymissiles.com
David_246
Trusted Contributor

Re: defunct processes

Hi,

Thanks for your feedback.
Don't like this habbit. It's hard to create a script that checks for zombie processes now. Anyway, I just use the "wc -l" command in extension now, to check for more than 2 zombie processes.

Again thanks for your support.

Regs David
@yourservice
Geoff Wild
Honored Contributor

Re: defunct processes

Have you tried?

ps -el |grep Z

Rgds...Geoff

Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
David_246
Trusted Contributor

Re: defunct processes

Hi Geoff,

Why do you grep for capital Z ?
Does "ps -e" show the process as being "ZOMBIE", or something? Unfortunetly I don't have a zombie process to check on right now.

Regs David
@yourservice
Mark Grant
Honored Contributor

Re: defunct processes

David,

what are you hoping to do with these zombies when you find them?

I you wont be able to kill them unless and it's good that you can't because in some instances an application will fail, or at least not work properly when it tries to issue a wait() on a process that it expects to be there. Also, if the process became a zombie as the result of it's parent dieing before the wait() then you will only get rid of it by re-booting.

It is worth noting that the only resource these things take up is some space in the process table and unless you are getting hundreds of them, they might be worth just leaving alone.

Just a few thoughts on the matter :)
Never preceed any demonstration with anything more predictive than "watch this"
David_246
Trusted Contributor

Re: defunct processes

Hi Mark,

Thanks for your time. However I do have a solution to kill a process that is initiating defuncts. Therefor I wrote a simple script to e-mail me whenever a defunct process shows up.

Regs David
@yourservice
Paula J Frazer-Campbell
Honored Contributor

Re: defunct processes

David

If in your script to check for defunct processes you store the defunct info you collect so:-

ps -ef | grep defunc | grep -v grep >/tmp/defunct_store

And the the next time you refer to this stored info to see if there is a real Zombie or you just caught an app clearing up.


HTH

Paula
If you can spell SysAdmin then you is one - anon
Geoff Wild
Honored Contributor
Solution

Re: defunct processes

Yes, ps -el |grep Z shows zombies...

This is a script I used to kill or report on zombies:


# Script to Kill Zombies
# Geoff Wild Jan 26, 1998
# kill ${i} commented out
#
# log file: /tmp/killzombies.log
logfile=/tmp/killzombies.log
if [ -f $logfile ];
then
rm $logfile
touch $logfile
else
touch $logfile
fi

#echo "/scripts/killzombies\n ">$logfile 2>&1
for i in `ps -el|grep -v SZ|grep Z|awk '{print $5}'`
do
ps -ef|grep -v grep|grep ${i} >>$logfile 2>&1
mailx -s "Check Zombie(s)" `cat /scripts/mailadmin.list` <$logfile
# kill -18 ${i}
done
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
David_246
Trusted Contributor

Re: defunct processes

Great work Geoff !!!

I'll implement it the way you've shown me.

Sorry Paula, but don't like to use temp-files for checking on duplicates or not. If I realy have a zombie process, but a second process stopping will jump in on the first check and another stopping process will jump in on the second time, I have a problem.

I strongly prefer Geoff's implementation.


Regs David

@yourservice