in reply to Force 2 'ctrl-c's to kill program
Try this:
#! perl -slw use strict; use 5.010; use Time::HiRes qw[ time sleep ]; $|++; $SIG{ INT } = sub { state $last = 0; if( ( time - $last ) > 2 ) { $last = time; return; } die 'Interupted by ^C^C'; }; while( 1 ) { printf "\rtum te tum: %f", time; sleep 0.1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Force 2 'ctrl-c's to kill program
by albob (Sexton) on Feb 11, 2013 at 17:34 UTC | |
by BrowserUk (Patriarch) on Feb 11, 2013 at 18:13 UTC | |
by Anonymous Monk on Feb 12, 2013 at 09:41 UTC |