Earindil has asked for the wisdom of the Perl Monks concerning the following question:

I have two different methods of pulling data from a remote node. If the first doesn't work, it should try the 2nd. For some reason, the first eval block works fine, after 10 seconds, it gives up and goes to the next. But, the second eval block never will time out. It just hangs the entire process. Any suggestions as to what might cause this? First version had two separate eval blocks, when that wasn't working, i tried nesting the 2nd eval block in the 1st one, but that didn't make a difference.
eval { local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required alarm 10; system("/nsh/bin/nexec $node \"date\" > /dev/null 2>&1"); alarm 0; }; if ($@) { ### Timed Out print "Block 1 Alarm, blkillhung $node\n"; &killhung($node); $CMOK = 1; eval { local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n req +uired alarm 10; system("rcmd -q -n $node \"date\" > /tmp/date.${node}" +); alarm 0; }; if ($@) { ### Timed Out print "Block 2 Alarm, killhung $node\n"; &killhung($node); $CMOK = 1; } else { $CMOK = 0; } }

Replies are listed 'Best First'.
Re: eval and alarm
by kyle (Abbot) on Oct 02, 2007 at 16:37 UTC
      Thanks. Was thinking it might have something to do with the "rcmd" script. I'll check out those links.