<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">> This sounds like exactly what I need, but it doesn't seem to</blockquote>
<div> > be working.<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">> It still freezes at the call to Does it make any difference that I am<br>
</blockquote><div> > not making a simple system call, but instead a call to a function in a<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> module?<br></blockquote><div><br> perlipc's POSIX workaround can help if the function has a<br> networking call with its own timeout which interferes with the<br> timeout you've set. Here's a couple of changes to demo the<br>
fix although perlipc warns this will bypass safe signals:<br><br> <br></div><div> use POSIX qw(SIGALRM); # <---<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> while(1)<br>
<div class="im">> {<br>> eval {<br>><br>> # local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required<br></div></blockquote><div> </div> POSIX::sigaction(SIGALRM, # <---<br> POSIX::SigAction->new(sub { die "alarm"; } ) )<br>
or die "Error setting SIGALRM handler: $!\n";<br> <br> > alarm 5;<br> > # $Scoop_a is my robot object<br><div><br> > $ret =<br> >
$Scoop_a->nxt->get_battery_level(</div><div class="im"> > $LEGO::NXT::Constants:: NXT_RET);<br> > alarm 0;<br>
>};<br> > ... <br></div><div><br><br>Of course,nothing helps if the function does this:<br><br> local $SIG{ALRM} = 'IGNORE';<br><br>-- <br>Charles DeRykus <br></div></div>