Interrupted system call and telnet.rb

P

Pete Kazmier

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
 
T

Tanaka Akira

Pete Kazmier said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top