develooper Front page | perl.perl5.porters | Postings from February 2003

Re: [PATCH] $SIG::UNSAFE

Thread Previous | Thread Next
From:
Gurusamy Sarathy
Date:
February 23, 2003 09:05
Subject:
Re: [PATCH] $SIG::UNSAFE
Message ID:
200302231704.h1NH4fB21476@smtp3.ActiveState.com
On Sun, 23 Feb 2003 17:15:45 +0200, Jarkko Hietaniemi wrote:
>We have been through all the possible namings (I think...)
>Please read the p5p threads (I think it was "safe signal safe tests").
>
>${^FOO} don't work for old Perls (the whole point being
>helpings backward compatibilities).

In general, I think deciding on ugly/unprecedented syntax
just to suit backward compatibility is taking things too far.
This is how we ended up needing Perl 6. :)

That said, I can understand not using ${^FOO} since it is a
compile-time error in older perl's and so makes it almost
impossible to write code that must work with the older perls.

>> Or even better yet C< $SIG{__ALL__} = 'IMMEDIATE' >?  This could
>> be extended in future to allow more specific behaviors:
>> C< $SIG{ALARM} = 'IMMEDIATE' >.
>
>While I like the syntax $SIG{__FOO__} does not work with -w since
>we have (had for a long time) a warning for unknown signals.
>
>No 'no warning' to get rid of the warning since again, backward
>compatibility is the primary reason for this whole dance.  I guess
>we *could* go for the recipe
>
>	local $^W = 0;
>	local $SIG{__ALL__} = ...;
>
>but that runs against another snag with old Perls and using
>new metaentries in %SIG: localizing hash elements leaves the
>keys hanging in the hash at the scope exit.

I don't see why that is a showstopper.  Pending a fix for the bug,
we should be able to treat an undefined value for $SIG{__ALL__}
internally the same as if the value did not exist.

If that is still unworkable for some reason, I would prefer
adding this stuff via an extension module/pragma, maybe even
via sigtrap.pm:

    use sigtrap;
    ...
    {
        sigtrap::set_local(ALARM => 'IMMEDIATE') if $] > 5.008;
        ...
    }

With a separate module, you could put it on CPAN and make it a
dependency for when running under older perls.

    use FancySignals;
    ...
    {
        set_local_signal ALARM => 'IMMEDIATE';  # noop on older perls
        ...
    }

set_local_signal() will need to have local() like behavior, but
that's easily done.  The Alias extension on CPAN has been doing
that for ages.


Sarathy
gsar@ActiveState.com

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About