my $prev_ctrlc = 0; $SIG{'INT'} = \&control_c_observed; sub control_c_observed { if ($prev_ctrlc ==0) { print "Second ctrl-c within 2 seconds required\n"; $prev_ctrlc = 1; sleep (2); $prev_ctrlc = 0; } else { print "This was the 2nd!Dying.\n"; exit; } }