1752676 Members
6116 Online
108789 Solutions
New Discussion юеВ

runaway and zombie ..

 
SOLVED
Go to solution
someone_4
Honored Contributor

runaway and zombie ..

Hey everything I have already done a search on this but I have yet to find my answer.
What is the difference between a runaway and a zombie process? I know you check for a zombie
#ps -ef defunct
but how do you find a runaway process or is it the same thing just a differnt name?
thanks

Richard
8 REPLIES 8
Rainer von Bongartz
Honored Contributor

Re: runaway and zombie ..

Richard,

you'll find answers to most questings on defuncts, runaways and zombies in this discussion

http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x6f717e990647d4118fee0090279cd0f9,00.html
He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
Ravi_8
Honored Contributor

Re: runaway and zombie ..

Hi,

runaway and zombie are different.when you created the child process(es) using fork(), the parent process has to wait untill child process to finish it's job. when the child finishes the job and dies then parent becomes zombie, if the parent dies before child completes it's job then child become orphan.
ususally in all the programs the parent process will be made to wait using wait(), but same doesn't apply to child, so the child finishes it's job and runaway.
never give up
Magdi KAMAL
Respected Contributor
Solution

Re: runaway and zombie ..

Look, Zambie process are those ones that when they finish working ( normal or abnormal exit ) they didn't find their parents executing a wait() function( waiting ) for them.

That's mean, consider a process P0 is doing a fork ( creates a copy of himeself ). The copy process is P1 called the child process and P0 is the parent process of P1.

If P1 finish his work ( normal or abnormal exit ) and P0 is not listening to him with a wait() function. So , P1 became a ZOMBIE process.

Alot of devellopers fall into this problem ( they are no more accepted into the system under their loginnames till these zambies are killed with a BOOT of course ) and the only way to kill them is REBOOTING the system.

Why booting, is that Zombies are considered as
1. Not live nor Died !!! So how to kill them.

If you need any help to avoid this miss programming, I have the solution just append your request .


Have a look in the following book :

Advanced Programming in the UNIX Environment.
Addison-Wesley
W. Richard Stevens.
Pages 195 and 196


Example:

P0 is the parent of P1.
P1 is the child of P0.

Normal programming is :
1. The parent P0 should execute a wait() function before a child process terminates normally or abnormally.
2. If Child process is not sure that his parent is waiting for him , he will execute the function getppid() function and executes an exit() as soon the function getppid() returns 1 ( that means that the unix init process (pid 1) is the actual parent).

unix init process ( pid 1) inheriets all orphan processes and immediately executes a wait() function as soon as a child process exits ( normal or abnormal exit ).

It's really the Client/Server model from a process point of view .

The manner by which the Unix model avoid that is :

P0 forks twice ,

P0 fork and gives P1
P1 fork and gives P2

1.The first instruction of P2 is to loop till getppid() returns 1; getppid means GetParentProcessIdentification. ( init process )
2. The first instruction of P1 is exit() function.
3. P2 became ORPHAN.
4. init process become the actual parent of P2.
5. The function getppid() returns 1 now.
6. The P2 process executes its task.
7. P2 terminates normally or abnormally.
8. init process executes an immediate wait() function.
9. P2 died without being ZAMBIE.

If you follow this protocol, your application will never have zombies processes.

Hope this explain the issue.
Wainting for any discussion.


Magdi

Magdi KAMAL
Respected Contributor

Re: runaway and zombie ..

Hi again Richard,

If you issue the command
ps -ef ? more

it will report under the column COMMAND:
The zombie process with the string :




Magdi
Sachin Patel
Honored Contributor

Re: runaway and zombie ..

I am reading these answers and I can't resist to reply. It is same as in nature. Child runway from parents. Parents die and child is orphan. Child dies and parent is zombie and so on.........

Sachin
Is photography a hobby or another way to spend $
Magdi KAMAL
Respected Contributor

Re: runaway and zombie ..

Hi all,

Ravi and Sachin : Really sorry !

When child finishes and it's parent is not listening for him ( with a wait() function ) then

CHILD become ZOMBIE and NOT the PARENT!!!

Magdi


Wodisch
Honored Contributor

Re: runaway and zombie ..

Hello Richard,

EVERY process becomes a zombie (output of "ps -el"
show a "Z" in the state column), when it exits, regardless
wether by being killed or by calling "exit()" or something
else. It stays in that state until its parent process has
received the signal "Death of a Child" (SIGCHLD). Then
the zombie disappears. Its a normal state!
The ONLY way to not become a zombie, is for the parent
to block that signal SIGCHL before calling "fork()".

A "runaway" process is just one, which eats up lots of
cpu time without stopping eventually. This is usually
considered to a bug, i.e. abnormal.

Just my $0.02,
Wodisch
Jack Werner
Frequent Advisor

Re: runaway and zombie ..

Hi,

You can test for a runaway process(one that is in a solid "R"un state) via: ps -efl | grep " R " This will also return the ps and the grep commands you issue to identify the bona-fide runaway(s). You can ignore these with a couple of piped greps.
i'm retired