A more portable solution would be, to remember the value of $SIG{INT} before you set it to 'IGNORE', and restore the old value whenever you want it.
That's precisely what local() is for.

Over the years, people are so wrapped in the discussions of local vs. my, that they tend to forget what a great concept local really is. Unfortunately, it doesn't work on lexical scalars.

my $foo; { local $foo; }
Can't localize lexical variable $foo at ...
Oddly enough, it does work on individual hash and array elements, even when those hashes and arrays are lexicals!
my %hash = (a => 'one', b => 'two', c => 'three' ); use Data::Dumper; { local $hash{b} = 'Hello!'; print Dumper \%hash; } print Dumper \%hash;
Unfortunately, if a localised hash element didn't exist in the outer scope, then when it's restored, it is merely set to undef, not deleted. So you end up with one hash element more than you had before. You can localise the entire hash — if it isn't a lexical, that is; but still...

In reply to Re: Re: Signals and 'IGNORE' by bart
in thread Signals and 'IGNORE' by hotshot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.