in reply to Signals and 'IGNORE'

The default behavior of $SIG{INT}, the keyboard interrupt, is determined by the OS. On *nixen it is the system's process termination function, exit(), and you can probably rely on a system doing its own version of that if signals exist at all. The *nix behavior is POSIX standard.

Perl does not set its own handler, so anything that leaves $SIG{INT} undefined will work.

{ local $SIG{INT}; }
or maybe [for self-documentation - thanks to broquaint for asking]
{ undef local $SIG{INT}; }
will do.

After Compline,
Zaxo

Replies are listed 'Best First'.
Horrible "undef local $foo;" (was: Re: Signals and 'IGNORE')
by bart (Canon) on Jan 06, 2003 at 13:30 UTC
    or maybe [for self-documentation - thanks to broquaint for asking]
    { undef local $SIG{INT}; }
    will do.
    Yuck. Please don't advice people to write this kind of junk. Rather, teach them about Perl's default behaviour: if you localize a scalar variable, it gets the value undef — unless you assign something to it. So
    local $foo;
    should be self-documenting enough. (If it isn't: learn Perl!) But not this... perversion.
      Did you not read the part "or maybe [for self-documentation -"?

      undef local $SIG{INT} is clearer in intention than local $SIG{INT}. Reading other's code I might question if it was a piece of kruft (lavaflow, whatever there calling it now)

      -Lee

      "To be civilized is to deny one's nature."
        undef local $SIG{INT} is clearer in intention than local $SIG{INT}.
        Not to me it isn't. It's actually more confusing. It immediately begs the question for me: "how come this coder doesn't know that all new variables are automatically born undef?". And then it has me question the quality of the remaining code. Or even question my own knowledge, wondering, "well, maybe there is a time when I need to undef that new variable explicitly that I don't know about". It's raising more questions than it's answering.

        Put another way, you do look funny when you wear both belt and suspenders, even though you make think you're just being safer or clearer about intent. Makes me wonder whether you're wearing both boxers and briefs as well.

        -- Randal L. Schwartz, Perl hacker
        Be sure to read my standard disclaimer if this is a reply.

        undef local $SIG{INT} is clearer in intention than local $SIG{INT}
        Allow me to disagree. I do not find it more readable, instead, I find this may qualify as obfuscation. This is not Perl. Well actually, it is, but I don't think it is normal Perl.

        If you insist on explicitely showing that this value is set to undef, please use a more common idiom:

        local $SIG{INT} = undef;
        The explicit assignment is still unnecessary, but at least it looks more harmless.