in reply to quiting program
Here, I simply define a subroutine handler for the 'INT' signal. Inside the sub, I keep track of how many times it was initiated (<cntrl>C hit counts) and exit the program on 3rd hit! ;-)use strict; my $hit_count = 0; $SIG{INT} = sub { if (++$hit_count > 3) { print "terminated!\n"; exit; } print "Hit!\n"; }; while (1) { sleep(1000); }
$"=q;grep;;$,=q"grep";for(`find . -name ".saves*~"`){s;$/;;;/(.*-(\d+) +-.*)$/; $_=["ps -e -o pid | "," $2 | "," -v "," "];`@$_`?{print"+ $1"}:{print" +- $1"}&&`rm $1`; print$\;}
|
|---|