#!/usr/bin/perl use strict; use warnings; my $killed=0; $SIG{INT}=sub{$killed++}; while (1) { # this may take some time sleep 1; last if $killed; } if ($killed) { print "cleaning up after getting a sig int\n" }else{ print "finished infinite loop, halting problem next\n" }