There is a potential for a race condition here. This is described in the Camel book (3rd Ed. - page 417). In brief, you need to do something like the following to protect against this.
eval { local $SIG{ALRM} = sub { ... }; alarm $timeout; eval { # operation you're waiting on }; alarm 0; }; alarm 0; die $@ if $@;
PN5
In reply to Re: Re: how can I timeout a function like "read" when reading from a socket
by Prior Nacre V
in thread how can I timeout a function like "read" when reading from a socket
by Goatee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |