If I tell Perl to explicitly ignore a signal, SIGINT has no effect:
$SIG{INT} = 'IGNORE';
my $count = 0;
say $count++ and sleep 1 while 1;
Then pressing Control-C, rather obviously, has no effect. If, on the other hand, I tell it to do nothing:
$SIG{INT} = sub { };
my $count = 0;
say $count++ and sleep 1 while 1;
Then pressing Control-C has an effect! It wakes up the program from its sleep() call and immediately increments the count. What's the difference between ignoring a signal and telling it to do nothing?
In my program, I'd like to have code run on SIGINT, without having it disrupt anything. I want something like:
$SIG{INT} = sub { say "Caught SIGINT!"; return IGNORED; }; # runs without disrupting sleep