in reply to Resuming from a SIG{INT}

jmccaf01,
I assure you that your code is working as you have coded it. I just think you didn't code it the way you wanted it. Try the following instead:
#!/usr/bin/perl use strict; use warnings; $SIG{INT} = sub { print "Program interuption detected!\n"; print "Press ENTER to continue or any other key to quit\n"; my $foo = <STDIN>; chomp $foo; die "\nTerminating at users request\n" if $foo; print "Resuming our regularly scheduled programming\n"; }; print "This would be your program starting up\n"; for ( 1 .. 10 ) { print "$_\n" for 1 .. 10; sleep 1; } print "This would be your program finishing cleanly\n";
Cheers - L~R

Replies are listed 'Best First'.
Re: Re: Resuming from a SIG{INT}
by kappa (Chaplain) on Mar 16, 2004 at 20:39 UTC
    You cheat :)

    Your example shows that if a signal handler that uses diamond operator is lucky enough not to interrupt another diamond operator it will probably usually most of the time work as expected.

      kappa,
      We completely have different interpretations of why the OP chose to read from STDIN during the main execution of the program. I was assuming it was to get the program to pause long enough to test and it was the extra carriage return(s) that were not desired.

      Cheers - L~R