Short version: I'm trying to pass an argument to a signal handler. However, when I do this, the handler starts immediately after the program starts. Why is this happening, and how can I fix it?
Details: there is the following line in my code: $SIG{ALRM} = \×up($number);. The signal processor itself:
sub timesup {
my $num = shift;
die "Time ran out.\nNumber was: $num\n"
}
When I run the program, it immediately starts the signal handler and dies with the specified message. I tested by generating a random value for $ number just before the line $SIG{ALRM}. The message about the swan song dies at random, so I think the argument itself is passed correctly. But the conclusion is immediate:
bassoon:$ ./myscript.pl
Time ran out.
Number was: 4
$SIG{ALRM} = \×up;, , . , .
? .