When using Perl 4.0 under HP-UX 11, $SIG{ALRM} is not working. Here is a chunk of code:
$timeout = 10;
$SIG{INT} = 'wrapup';
$SIG{TERM} = 'wrapup';
$SIG{ALRM} = 'timeout';
alarm $timeout;
print ROOTLOG "Before while loop - timeout length=$timeout\n";
$i = 1;
while ($i < 20) {
sleep 2;
print ROOTLOG "Inside while loop: call $i\n";
&flush(ROOTLOG);
$i++;
}
Now, what should happen here is the loop should go for 10 iterations and then SIG{ALRM} should break the code and go to the 'timeout' subroutine. The alarm is never sent and the loop finishes after 20 iterations. Has anyone else had any problems with SIG{ALRM}?
Thanks
$timeout = 10;
$SIG{INT} = 'wrapup';
$SIG{TERM} = 'wrapup';
$SIG{ALRM} = 'timeout';
alarm $timeout;
print ROOTLOG "Before while loop - timeout length=$timeout\n";
$i = 1;
while ($i < 20) {
sleep 2;
print ROOTLOG "Inside while loop: call $i\n";
&flush(ROOTLOG);
$i++;
}
Now, what should happen here is the loop should go for 10 iterations and then SIG{ALRM} should break the code and go to the 'timeout' subroutine. The alarm is never sent and the loop finishes after 20 iterations. Has anyone else had any problems with SIG{ALRM}?
Thanks