The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Sig::PackageScoped::Paranoid - All $SIG{__DIE__} and $SIG{__WARN__} assignments are module-scoped

SYNOPSIS

  use Sig::PackageScoped::Paranoid;

  package Foo;

  $SIG{__DIE__} = sub { die "in Foo" };

  package Bar;

  die "not in Foo";

DESCRIPTION

Whenever a handler is assigned $SIG{__DIE__} or $SIG{__WARN__} the effects are now scoped to the package that did the assignment.

This module needs to be loaded before any other module that assigns to $SIG{__DIE__} or $SIG{__WARN__} for this to work.

This will catch any attempt to set $SIG{__DIE__} or $SIG{__WARN__} and force it to be package-scoped. This will probably break things like CGI::Carp so use it with care. OTOH, modules that globally set these signals deserve to be broken.

The fact that this works scares me deeply. It is not recommended that you use this code in any sort of production environment.

AUTHOR

Dave Rolsky <autarch@urth.org>