perl -e ' BEGIN { *CORE::GLOBAL::exit = sub { goto FASTCGI_NEXT_REQUEST; }; } while (1) { eval { that_cgi_script() }; FASTCGI_NEXT_REQUEST: last; } sub that_cgi_script { local $SIG{__DIE__} = sub { print "
error: $_[0]"; exit; print "XXX\n" };
print "before buggy code\n";
eval { buggy_code() };
print "after buggy code\n";
}
sub buggy_code {
die "error!";
print "after die\n";
}
'
####
*CORE::GLOBAL::die = sub {
if ($SIG{__DIE__}) {
my $s = $_[0];
$s .= sprintf " at %s line %d.\n", (caller)[1,2] if $s !~ /\n\z/;
$SIG{__DIE__}->($s);
}
};