I want to specify a signal handler in Perl, but using a number, not a name. Is this possible succinctly? The lack of symmetry with slaughter sticks out especially. For example, instead of
$SIG{USR2} = \&myhandler;
I would like to say
$SIG{12} = \&myhandler;
The best thing I have at the moment is to "use Config" and navigate $ Config {sig_name} based on the code per peroc perlipc. It is verbose and seems overly complex.
Rationale: I have wanted this on two occasions lately.
1: I get started by a buggy-parent process that incorrectly sets the signals that concern me, and I just want to reset everything to default. e.g. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=679630 The goal would be simple and brute force:
foreach my $i (1..32) { $SIG{$i} = 'DEFAULT'; }
2: , , script. , , , . , , , , . - - :
$ret = system("./other-program");
$SIG{$ret & 127} = 'DEFAULT';
kill $ret & 127, $$;