Mega Code Archive
Catching the sigINT signal
#!/usr/bin/perl
use strict;
my $interruptions = 0;
$SIG{INT} = \&handle_interruptions;
while ($interruptions < 3) {
print "waiting.\n";
sleep(5);
}
sub handle_interruptions {
$interruptions++;
warn "interrupted ${interruptions}x.\n";
}