Interrupted system call and telnet.rb

Has anyone else experienced an interrupted system call when using
telnet.rb? I use it frequently to do a large provisioning job which
very rarely completes because read(2) gets interrupted. The call to
read(2) in made by this line in telnet.rb:

     c = @sock.sysread(1024 * 1024)

Consequently, an exception is thrown of the type Errno::EINTR which
causes my program to fail in the middle of a telnet session. I've
fixed the problem by patching my telnet.rb with the following:

--- /usr/lib/ruby/1.8/net/telnet.rb~ 2004-10-05 13:45:15.000000000 -0400
+++ /usr/lib/ruby/1.8/net/telnet.rb 2005-01-18 15:39:53.000000000 -0500
@@ -584,6 +584,8 @@
             yield nil if block_given?
           end
           break
+ rescue Errno::EINTR
+ retry
         end
       end
       line

I'm not sure why the read(2) system call in being interrupted, but I
do know that restarting the call fixes my problem. Just curious if
anyone else has come across this problem.

I am using ruby 1.8.2 on a debian box.

Thanks,
Pete

In article <873bwujbzp.fsf@coco.kazmier.com>,
  Pete Kazmier <pete-temp-20050120@kazmier.com> writes:

Has anyone else experienced an interrupted system call when using
telnet.rb? I use it frequently to do a large provisioning job which
very rarely completes because read(2) gets interrupted. The call to
read(2) in made by this line in telnet.rb:

     c = @sock.sysread(1024 * 1024)

I think there is another option: readpartial. It restarts read(2) on
EINTR (and EAGIN). It is available since 1.8.3, though.

···

--
Tanaka Akira