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:
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!
I'm having some troubles using eval and alarm in threads:
Code follows:
The thread is created and runs fine until the 10sec timeout.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; }
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: threads eval/alarm problem
by liz (Monsignor) on Mar 27, 2004 at 12:08 UTC | |
Re: threads eval/alarm problem
by diotalevi (Canon) on Mar 27, 2004 at 06:15 UTC |
Back to
Seekers of Perl Wisdom