$SIG{INT} = \&zap; sub zap { print "You zapped me!\n"; # do some stuff # you can't die; # kill 6 which is ABRT doesn't work (crash) # under strict in indigoperl for some reason kill 15, $$; # TERM = 15, forgot where you import it from } sleep 1 while 1; #### #!/usr/bin/perl -w use strict; use sigtrap 'handler' => \&CLEANUP, 'INT'; # $SIG{INT}=\&CLEANUP; =head1 modulus (%) explained =pod Binary ``%'' computes the modulus of two numbers. Given integer operands $a and $b: If $b is positive, then $a % $b is $a minus the largest multiple of $b that is not greater than $a. If $b is negative, then $a % $b is $a minus the smallest multiple of $b that is not less than $a (i.e. the result will be less than or equal to zero). =cut $|++; # i like a free flow of ideas &theloopy; sub theloopy { my($a,$b)=(0,0); while(11) { $a = '|' if(($b % 4) == 1); #| $a = '/' if(($b % 4) == 2); #/ $a = '-' if(($b % 4) == 3); #- $a = '\\' if(($b % 4) == 0); #\ print "\r $a$a$a infinite loop"; select(undef,undef,undef,0.25); # sleep $b++; } } sub CLEANUP { print "\n caught \$SIG{INT}",@_,"\n"; my $shallwedie = ; print "shall we die (666)\n"; $shallwedie = ; chomp $shallwedie; # $SIG{'ABRT'} = DEFAULT; # just make sure # do your cleanup stuff # and then kill yourself #kill 'ABRT', $$; # ABRT = 6 if($shallwedie eq '666') { print "the dying\n"; kill 'TERM', $$; # TERM = 15 kill 6, $$; } else { print "the loopy\n"; &theloopy(); } #exit; }