All I am reading Network Programming with Perl by Lincoln Stein. I am having trouble on page 443, "Handling HUP and other Signals", here's a snip of the code which I am having trouble with,
sub reap_child {
while ( (my $child = waitpid(-1,WHNOHANG)) > 0) {
$CHILDREN{$child}->($child) if ref $CHILDREN{$child} eq 'CODE';
delete $CHILDREN{$child};
}
}
what's does this line do,
$CHILDREN{$child}->($child) if ref $CHILDREN{$child} eq 'CODE'? Is it saying
$CHILDREN{$child} = $child if ref $CHILDREN{$child} eq 'CODE'? What does the value
'CODE' means?
sub kill_children {
kill TERM => keys %CHILDREN;
sleep while %CHILDREN;
}
what does </code>"kill TERM => keys %CHILDREN;"</code> mean? Send a Kill TERM signal to all children pid? Not use to seing "TERM => (value ... values + n". Thanks.