{ my $num_ctrlc = 0; $SIG{'INT'} = sub { print "Got " . ++$num_ctrlc . " ctrl-c\n"; exit if $num_ctrlc > 2; } }