[Discuss] Making read() non-restartable

Peter Scott Peter at PSDT.com
Tue Dec 5 15:27:18 PST 2006


At 02:40 PM 12/5/2006, you wrote:
>It is a perl thing.  read() is a perl call that does its own buffering.
>FOr sockets, you want either recv() or sysread().  Those are the only calls
>that will work with select().  If you're trying to do a read-with-timeout,
>you may want to consider using select()/recv() instead of SIGALRM.

Wise advice.  Which I would have heeded if I'd written the code that 
called read(), but it was buried several layers down in a CPAN module 
that I neglected to tell you about.  (Mail::POP3Client calls getline() 
on an IO::Socket::INET, which method is in IO::Handle, which calls 
Perl's getline() function, which presumably calls read() 
eventually.)  The answer: die() inside the ALRM handler and eval the 
top-level call for timing out.
-- 
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com/
http://www.perlmedic.com/



More information about the Discuss mailing list