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

Re: [PATCH] $SIG::UNSAFE

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
February 23, 2003 07:35
Subject:
Re: [PATCH] $SIG::UNSAFE
Message ID:
20030223150920.GG351@Bagpuss.unfortu.net
On Sun, Feb 23, 2003 at 06:37:28AM -0800, Gurusamy Sarathy wrote:
> On Sun, 23 Feb 2003 14:45:06 +0200, Jarkko Hietaniemi wrote:
> >Here's a patch for enabling in runtime the Old Way Of Signals.
> >After much waffling I settled on the $SIG::UNSAFE name for the
> >control variable, which (I think) falls at the right balance of
> >backward portability, least danger of stomping on a user variable,
> >and aesthetics.
> 
> Not having looked at the patch, $SIG::UNSAFE doesn't seem all
> that consistent to me.  Is there a precedent for this style
> of setting a flag?
> 
> IOW, why not C< ${^UNSAFE_SIGNALS}++ >?

$ perl5.00404 -e '${^UNSAFE_SIGNALS}++'
syntax error at -e line 1, near "{^"
Execution of -e aborted due to compilation errors.
$ perl5.00503 -e '${^UNSAFE_SIGNALS}++'
syntax error at -e line 1, near "{^"
Execution of -e aborted due to compilation errors.

I think it was felt unwise to introduce something that would be a syntax
error on earlier perl versions, given that it is a feature likely to be
wanted for scripts that have to work across several perl versions. In fact,
it's a feature designed to give newer perl the same semantics as those
older perl versions, which I presume is intended to allow older scripts to
work as expected on recent perl versions, and hence to allow sysadmins to
upgrade without things breaking.

> Or even better yet C< $SIG{__ALL__} = 'IMMEDIATE' >?  This could
> be extended in future to allow more specific behaviors:
> C< $SIG{ALARM} = 'IMMEDIATE' >.
> 
> C< $SIG{__ALL__} = 'IGNORE' > would of course disable signal
> handling altogether, which is something one may want to do
> when executing unsafe code or when creating threads or when
> running embedded in another application.

I like this idea as described. But it has implications:

Conceptually what happens when I go $SIG{__ALL__} = 'DEFAULT'; ?
And presumably local $SIG{__ALL__} = 'IGNORE'; restores all old signal
handlers at scope exit?

In what state does

{
  local $SIG{__ALL__} = 'IGNORE';
  $SIG{ALARM} = \&pie;
}

leave the alarm handler?

Nicholas Clark

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