|
Posted by Ben Morrow on June 10, 2008, 10:50 am
Please log in for more thread options
>
> As a failsafe, I've tried using $SIG to no avail, as the alarm()
> doesn't appear useful when reading from the file handle.
>
> local $SIG = sub { die "Alarm went off!\n"; };
> while(<$readFH>) {
> last if m/^END$/;
> # do stuff
> }
AFAIK alarm doesn't work on Win32. Probably the simplest alternative is
to create a second thread which waits for the timeout and then kills the
first thread: you will need to test to make sure that a thread waiting
for IO can be killed.
Ben
--
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
'Alcestis') [ flame, and falls out of sight. ] ben@morrow.me.uk
|