http://qs321.pair.com?node_id=340175

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

Hi!

I'm having some troubles using eval and alarm in threads:
Code follows:
use threads; my $thread = threads->new(\&mysub, $var1, $var2); for (;;) { # here is an infinite loop # print seconds to see where it freezes } sub mysub { my ($var1, $var2) = (shift, shift); eval { local $SIG{'ALRM'} = sub { die("stop\n"); }; alarm(10); while (1) { # infinite loop } alarm(0); }; if ($@) { print "$@\n"; } return; }
The thread is created and runs fine until the 10sec timeout.
When this amount of time is reached, the whole script freezes, and 2 or 3 sec after, it crashes displaying "Alarm clock".
Nothing is in $@.

perl -v: This is perl, v5.8.2 built for cygwin-thread-multi-64int

Any ideas?
Thanks!

Edited by Chady -- added readmore tags.