in reply to timeout for ?
From "Advanced Perl Programming":
this will wait ten seconds for someone to enter something. the alarm(0) is to reset the timer if something does get entered (so &timed_out won't get called).
if you want high resolution timing (like 2.35), ye olde dromedary suggests using syscall to call the system timer routines (itimer).
-- ar0n || Just Another Perl Joe
update$SIG{ALRM} = \&timed_out; eval { alarm(10); $buf = <>; alarm(0); }; if ($@ =~ /BLAH/) { print "Timed out."; } sub timed_out { die "BLAH" }
this will wait ten seconds for someone to enter something. the alarm(0) is to reset the timer if something does get entered (so &timed_out won't get called).
if you want high resolution timing (like 2.35), ye olde dromedary suggests using syscall to call the system timer routines (itimer).
-- ar0n || Just Another Perl Joe
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: Re: timeout for ?
by tye (Sage) on Aug 29, 2000 at 18:25 UTC |
In Section
Seekers of Perl Wisdom