On 12/7/06, hOURS <[EMAIL PROTECTED]> wrote:
Thanks for trying, but this right here is the heart of the matter. I'd be
using alarm to time a certain thing. It seems to me, any explanation of how
to do that, be it plain English or sample code has to incorporate that thing.
My program in a nutshell goes:
Blah blah blah the beginning part
require someprogramthatmayhaveaninfiniteloop.pl
Blah blah blah the ending part
Note that's not the literal code. :)
As it stands if someprogramthatmayhaveaninfiniteloop.pl does go on
forever I will never get to the ending part. How would one add alarm to this
such that the ending part gets executed regardless?
Fred Kittelmann
> Where is the thing being timed? I understand something is being given 5
> seconds, but what?
Hm... somebody else may explain this much better than I;
hOURS,
The example from the perlfunc should do what you want:
my $timeout = 3600; # 1 hour
eval {
local $SIG{ALRM} = sub { die "longRunningModule timed out\n" };
alarm $timeout;
require longRunningModule;
alarm 0;
}
if ($@) {
if ($@ =~ /timed out/) {
# timeout
} else {
# some other error
}
}
If that isn't doing what you need, you need to provide some sample
code, and a clearer explanation.
Best,
-- jay
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential
daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org
values of β will give rise to dom!