----- Original Message -----
From: Orlando Andico
To: The Main Philippine Linux Users' Group (PLUG) Discussion List
Sent: Monday, November 21, 2005 1:21 PM
Subject: Re: [plug] Perl: handling blocking reads "nicely"
but does signal() interfere with blocking I/O?
yes
according to perldelta for version 5.8 if there is no pending I/O
(e.g. read is blocking on a socket) then alarm() will interrupt it
successfully.
but if I/O is pending, the I/O will complete before the alarm() is
delivered.
this behavior is ok with me. :)
could you try this template?
SIG{ALRM} = sub { die "timeout" };
eval {
alarm(1);
# your operations here
alarm(0);
};
if ($@) {
if ($@ =~ /timeout/) {
# timed out; do what you will here
} else {
alarm(0); # clear the still-pending alarm
die; # propagate unexpected exception
}
}
fooler.
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
[email protected] (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph