hi all,

i wrote a program that forks, it runs well, but once
the child is done with its job, it did not become a
zombie (so that reaper can kill it), instead it went
into a sleep state, and i'm not sure why/what makes it
go there? any pointers? i must have missed out
something.

Conan

..
..
..
die "fork: $!" unless defined ($pid = fork);
if ($pid) { #parent records child's pid
 $children{$pid} = 1;
 $children++;
}
else { #child
# do some useful things
exit;
}

$SIG{INT}  = \&terminator;
$SIG{CHLD} = \&reaper;

sub terminator { # signal handler for SIGINT
        local($SIG{CHLD}) = 'IGNORE'; 
        kill 'INT' => keys %children; #kill all child 
        exit;
}
sub reaper { # to take care of zombies
    $SIG{CHLD} = \&reaper;
    my $pid = wait;
    $children --; #decrement number of children
    delete $children{$pid}; #delete record of children
}
..
..
..


=====
lIvE bY yOuR iNsTiNtS !!!
[EMAIL PROTECTED]

__________________________________________________
Do You Yahoo!?
Yahoo! Kickin' Party - Win a 5-star getaway to exotic Bali!
http://kickin.yahoo.com.sg

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to