Hi all,

I have been attempting some signal blocking, as done in the Cookbook,
second edition, recipe 16.20:

### Begin code
use POSIX qw(:signal_h);

$SIG{INT} = $SIG{TERM} = sub
{
        exit 0;
}
while ( 1 ) {
        my $sigset = POSIX::SigSet->new(SIGINT, SIGTERM);
        my $old_sigset = POSIX::SigSet->new;
        sigprocmask(SIG_BLOCK, $sigset, $old_sigset)
                or die "Could not block signals\n";
        sleep 30;
        defined sigprocmask(SIG_UNBLOCK, $old_sigset)
                or die "Could not unblock signals\n";
}
### End code

My problem is that when I send the process a TERM signal via the kill
command, it finishes the sleep that it's currently doing, and then does
one more iteration of the while loop before exiting.  By my reasoning,
it should just finish the sleep that it's currently doing, and then once
the signals are unblocked the signal handler for TERM should be entered,
and that would cause the program to exit.  Is it my logic that's wrong,
or is the code doing something funky?

Thanks,

Jeff Eggen
IT Programmer Analyst
Saskatchewan Government Insurance
Ph (306) 751-1795
email [EMAIL PROTECTED]
************DISCLAIMER*************
This e-mail and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed.  If 
you are not the named addressee, please notify the sender immediately by e-mail 
if you have received this e-mail by mistake and delete this e-mail from your 
system. If you are not the intended recipient you are notified that using, 
disclosing, copying or distributing the contents of this information is 
strictly prohibited.
************DISCLAIMER*************

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to