hi all,
 
thought to explain why a zombie cannot be killed. 
 
main()
{
         int pid;
    
        pid = fork();   /*the integer pid now holds the return value of
                       fork, fork returns the child process id in
                       parent and 0 in the child process */
   
        if(pid == 0) {   /*the body of the if-statement is executed */
                 sleep(1);  /* only in the child*/
                 exit();
        }
        sleep(30);       /*the parent, straight away goes to sleep*/
}

the above program is a very simple one, all ought to understand it.  
 
fork is a system call used to generate child process. so once we call fork, 
we get two process, one the parent and the other the child.
                                      |
                                      |
                                      |
                                      |
                                   fork()
                                    /   \
                                   /     \
                                  /       \
                                 /         \
                           parent    child 
   
fork returns twice, once in parent and once in child.  In the parent fork 
returns 
the process id(PID) of the child, and in the child it returns 0.
 
 
so the body of the if-statement is executed in the child process only the child 
process sleeps for one second and then exits ie terminates.  the parent process 
goes on to sleep for thirty more seconds. please note that the child process 
was made to sleep for one second to make sure that the parent is sleeping when 
the child exit()'s.
 
 
and then by definition of a zombie process, the child should have become a 
zombie process
because its exit status is not known by the parent, because the 'irresponsible' 
parent was 
sleeping when its child died.
 
 
the below few lines are the last lines of the output of 'ps -l a' command.
 
 
100 S      0   412    408   0   75    0 -   554  11d2b8    pts/1        0:00 
/bin/bash
000 S      0   417    261   0   72    0 -   309  12228a    tty1          0:00 
./a.out
044 Z       0  418   417   0   72    0 -     0   11ce8a    tty1           0:00 
[a.out <defunct>]
000 R      0   420    412   0   77    0 -   669           -     pts/1         
0:00 ps -l a
 
and can we see that the parent with pid number 417 is sleeping and the child 
with pid 418 is now a defunct process with status shown as Z, meaning Zombie 
process( make sure you switch terminal and give command 'ps -l a' before 30 
thirty seconds to view this behaviour).
 
understand why trying to kill a Zombie process just wont work.  simply because 
its allready dead.
 
once the parent wakes up after 30 seconds it gets the status of the child 
process and the zombie child vanishes( 'ps -a l' after the parent has 
terminated to see this).  
 
another way to get rid of the zombie is to kill the parent process, in this 
case 'kill -9 417' will kill the parent and take out the zombie as well, 'ps -a 
l' after killing the parent to see that the zombie has vanished.
 
please reply to the post if i have made a mistake in grasping the concept 
and/or if things are out of context and/or if there is something more to be 
explained.  also please explain if Zombies can be 'eliminated' in any other 
way, i remember to have seen code to eliminate 
all the zombie processes. is this possible.
 
justin
 

 

                
---------------------------------
Do you Yahoo!?
 The all-new My Yahoo! – Get yours free!    
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
/pipermail/mailinglist_ilug-cochin.org/attachments/20041203/79322eab/attachment.htm
From [EMAIL PROTECTED]  Sat Dec  4 12:57:33 2004
From: [EMAIL PROTECTED] (justin joseph)
Date: Sat Dec  4 12:57:37 2004
Subject: [Mailinglist] please suggest an internel modem.
Message-ID: <[EMAIL PROTECTED]>

hi all,
 
lightening has damaged my internel modem(dfm 560is). can some one please 
suggest an internal modem which works with atleast 2.4.18. the damaged one 
worked only with 2.4.4
 
every time the module for the modem is being loaded the booting process stops, 
no use restarting too.  i could only manage to boot up after removing the 
modem.  this is how i decided that the modem is damaged.
 
please do not suggest an externel modem, cannot afford one.
 
justin

                
---------------------------------
Do you Yahoo!?
 Yahoo! Mail - 250MB free storage. Do more. Manage less.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
/pipermail/mailinglist_ilug-cochin.org/attachments/20041203/6cc3e9fc/attachment.htm
From [EMAIL PROTECTED]  Sat Dec  4 13:13:17 2004
From: [EMAIL PROTECTED] (Rajesh)
Date: Sat Dec  4 13:13:23 2004
Subject: [Mailinglist] please suggest an internel modem.
In-Reply-To: <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>

 --- justin joseph <[EMAIL PROTECTED]> wrote:

> hi all,
>  
> lightening has damaged my internel modem(dfm 560is).
> can some one please suggest an internal modem which
> works with atleast 2.4.18. the damaged one worked
> only with 2.4.4
>  
> every time the module for the modem is being loaded
> the booting process stops, no use restarting too.  i
> could only manage to boot up after removing the
> modem.  this is how i decided that the modem is
> damaged.
>  
> please do not suggest an externel modem, cannot
> afford one.
>  
> justin
> 
>               
please buy a kobian modem with netodragon chip 
and linux download driver from www.netodragon.com

for more details contact after getting the device and
driver



________________________________________________________________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony

Reply via email to