Subject: | Does not restore flags if code within UNSAFE_SIGNALS fails |
The attached perl script demonstrates that PL_signals is not restored if the code block within UNSAFE_SIGNALS throws an exception.
What's expected: the script should hang, because the final endless() call is not within a UNSAFE_SIGNALS block.
What's happening: the alarm handler is functional.
Subject: | unsafe_signals.pl |
#!/usr/bin/perl
use strict;
use warnings;
use Inline C => 'DATA';
use Perl::Unsafe::Signals;
my $impl = shift || 'c';
$SIG{ALRM} = sub { die "Alarm!"; };
alarm(1);
eval {
UNSAFE_SIGNALS {
fails();
#does_not_fail();
};
};
if ($@) {
warn "as expected, fails() fails: $@";
}
endless(); # no UNSAFE_SIGNALS, so it's supposed to hang
__END__
__C__
void endless() {
while(1) {
sleep(1);
}
}
void fails() {
croak("This fails");
}
void does_not_fail() {
}