sub long { 1 while 1 } $SIG{INT} = sub { die "got int\n" }; eval {long}; print "got err: $@\n" if $@; __END__ $ ./perl /tmp/p got err: got int $