If I tell Perl to explicitly ignore the signal, SIGINT has no effect:
$SIG{INT} = 'IGNORE'; my $count = 0; say $count++ and sleep 1 while 1;
Then pressing Control-C obviously has no effect. If, on the other hand, I tell him to do nothing:
$SIG{INT} = sub { }; my $count = 0; say $count++ and sleep 1 while 1;
Then pressing the Control-C button has an effect! It wakes the program from the sleep () call and immediately increments the counter. What is the difference between ignoring a signal and telling it to do nothing?
In my program, I would like to run SIGINT code without breaking anything. I need something like:
$SIG{INT} = sub { say "Caught SIGINT!"; return IGNORED; };
perl signals
cytzol
source share