fxmakers has asked for the wisdom of the Perl Monks concerning the following question:
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; }
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 |