ChrisDennis has asked for the wisdom of the Perl Monks concerning the following question:

I'm not sure if this is a question or a meditation really.

I asked a recent question about a problem with open3(). It turned out that the problem was really with my use of local signal handlers.

The following code works with 5.10.1 but not with 5.14.2:

#!/usr/bin/perl use strict; use warnings; print "starting pid=$$\n"; my $I = 0; { my $pid = 0; sub handler { my $sig = shift; $I += 1; print "caught $sig\n"; local $SIG{$sig} = 'IGNORE'; # doesn't work with local!! kill($sig, -$$); print "end of handler\n"; } local $SIG{INT} = \&handler; kill('INT', $$); } print "ending I=$I\n";

With 5.10.1, it calls handler() twice and then exits with I=2; with 5.14.2 it calls the handler many times before crashing with a segfault.

Removing the local from the inner $SIG{$sig} allows it to work with 5.14.2, which makes sense if I'm right in thinking that that command changes the immediately-containing signal handler, and not the global one.

So my question is: Since this can break existing (poorly written) code, is this a known effect, and if so, is it documented?

cheers

Chris