Errno::EPIPE being caused by $DEBUG

Hi all,

Solaris 9
Ruby 1.6.8 and 1.8.0p2

I noticed that when I run a TCPServer in debug mode, I hit Errno::EPIPE
errors. Here are a couple quick scripts you can verify with - just
start the server in one terminal (with -d), then run the client in
another:

tcpserv.rb

require "socket"
t = TCPServer.new(“localhost”,8888)
addr = t.addr
addr.shift

while true
Thread.start(t.accept) do |s|
while x = s.gets
puts "Got: " + x
s.puts(x)
end
end
end

tcpclient.rb

require “socket”

s = TCPSocket.new(“localhost”,8888)

1.upto(100){
s.puts(“Hello”,“World”)
rv = s.gets
puts “Received: #{rv}”
}

s.close

Running this code in standard mode seems to work fine, however. I
tried: trap(“PIPE”,“IGNORE”) but that didn’t seem to do anything.
Should I use some other trap code? Is this a bug?

Regards,

Dan

···


a = [74, 117, 115, 116, 32, 65, 110, 111, 116, 104, 101, 114, 32, 82]
a.push(117,98, 121, 32, 72, 97, 99, 107, 101, 114)
puts a.pack(“C*”)

Hi,

I noticed that when I run a TCPServer in debug mode, I hit Errno::EPIPE
errors. Here are a couple quick scripts you can verify with - just
start the server in one terminal (with -d), then run the client in
another:

tcpclient.rb wrote 200 packets, and read 100 times then close the
socket, so that the connection lost, EPIPE raised.

Then without ‘-d’ unhandled exception terminated the socket, but with
‘-d’ uncaught exception terminates the whole interpreter for debugging
purpose. The solution should be

tcpserv.rb

require “socket”
t = TCPServer.new(“localhost”,8888)
addr = t.addr
addr.shift

while true
Thread.start(t.accept) do |s|
begin
while x = s.gets
puts "Got: " + x
s.puts(x)
end
rescue
# catch all exceptions; do nothing
ensure
s.close
end
end
end

						matz.
···

In message “Errno::EPIPE being caused by $DEBUG” on 03/05/02, Daniel Berger djberge@qwest.com writes: