As always there are multiple solutions but select is nicer.my $line; eval { local $SIG{ALRM} = sub { die "alarm clock restart" }; alarm 10; $line = <$child>; alarm 0; }; if ($@) { if ($@ =~ /alarm clock restart/) { print "$$ alarm triggered\n"; next; } else { die "$$ Other error $@\n"; } }
In reply to Re: how can I timeout a function like "read" when reading from a socket
by UnderMine
in thread how can I timeout a function like "read" when reading from a socket
by Goatee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |