| |
Catching Control-C in perl
$SIG{INT} = sub { die(" exiting\n"); };
or more generally :
$SIG{INT} = \&handler;
sub handler { die(" exiting\n"); }
Remember that if you want to control-c out of a loop that happens to be
making repeated calls to system(), you'll want some delay in the loop
so that you spend a bit of time in perl and not just in subshells:
sleep(1);
or, sub second sleeps:
select(undef, undef, undef, 0.1);
or even:
use Time::HiRes;
sleep(0.1);
keywords: signals, interrupts, subsecond
date: 05/28/2009
|