This patch fixes a problem that can be reproduced with example.rb:
------------------------------------------ ruby-1.8.0-preview2
— io.c.orig 2003-03-22 00:09:32.000000000 +0200
+++ io.c 2003-03-22 00:39:32.000000000 +0200
@@ -710,7 +710,7 @@
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
-
if (len - n > 0) {
-
if (len - n >= 0) { clearerr(f); return len - n; }
···
------------------------------------------ example.rb
#!/usr/bin/env ruby
require ‘fcntl’
f = IO.popen(“date; sleep 2; date”)
f.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK)
while true
begin
s = f.read(1024) or break
puts s
rescue Errno::EWOULDBLOCK
puts(“would block”)
sleep(1)
end
end
Have fun!
–
ulf