Hello,
Please see the code below.
I block the signals in statement 1, and unblocked it in parent
(statement 2) and child (statement 3).
But, is the statement 2 needed or not?
Should I unblock it once in child or twice in both parent and child?
(if unblocking once is enough, then I believe parent and child will
share the signals).
Thanks!
while (!$DONE)
{
next unless my $sock = $listen_socket->accept;
my $signals = POSIX::SigSet->new(SIGHUP,SIGINT,SIGTERM,SIGCHLD);
sigprocmask(SIG_BLOCK,$signals); # statement 1
my $child = fork();
die "[EMERG] can't fork $!\n" unless defined $child;
if ($child) {
$status{$child} = 1;
sigprocmask(SIG_UNBLOCK,$signals); # statement 2
$sock->close or die "[EMERG] can't close established socket\n";
} else {
$SIG{HUP} = $SIG{INT} = $SIG{TERM} = $SIG{CHLD} = 'DEFAULT';
sigprocmask(SIG_UNBLOCK,$signals); # statement 3
$listen_socket->close or die "[EMERG] can't close listen socket\n";
my $c = <$sock>;
handle_the_content($c);
$sock->close or die "[EMERG] can't close established socket\n";
exit 0;
}
}
--
J. Peng - [EMAIL PROTECTED]
Professional Chinese Squid supports
http://SquidCN.spaces.live.com/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/