$ perl -le'$SIG{INT}=sub{print "cleanup"};sleep 100;END{print "goodbye"}' # here I hit Ctrl-C cleanup goodbye $