Subject: | base.pm doesn't honor already installed $SIG{__DIE__} handlers |
The latest version of base.pm overwrites global $SIG{__DIE} here:
# Make sure a global $SIG{__DIE__} makes it out of the localization.
$SIG{__DIE__} = $sigdie if defined $sigdie;
Test suite is 3 files:
1. test.cgi
2. Foo.pm
3. Bar.pm
test.cgi
=======================================================================
#!/usr/bin/perl
use strict;
$SIG{__DIE__} = sub {
print "We died in peace!\n";
};
require Bar;
Bar::test();
1;
=======================================================================
Foo.pm
=======================================================================
package Foo;
sub test() {
print "I am doing nothing!";
}
1;
=======================================================================
Bar.pm
=======================================================================
package Bar;
use base qw(Foo);
sub test {
print "I am doing nothing and then die!\n";
die "died!";
}
1;
=======================================================================
All files in the test suite should be placed in the same directory and
then test.cgi should be run. With the latest version of base.pm (2.12)
this is the output that I get after running test.cgi --
I am doing nothing and then die!
died! at Bar.pm line 7.
Expected output --
I am doing nothing and then die!
We died in peace!
died! at Bar.pm line 7.
Note "We died in peace!" line in the second output which was printed by
my die handler which seems to be overwritten by base.pm in the first output.
Commenting out the following line in base.pm fixes the problem:
$SIG{__DIE__} = $sigdie if defined $sigdie;