Author: J. PengJ. Peng
Date: May 4, 2008 01:41
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
|