$ perl -e '$SIG{INT} = sub { die "Got signal" }; while() {};' [Press CTRL+C] Got signal at -e line 1.