In <F211YSxclUubIKgnpcY0000ac67 / hotmail.com>
On Sun, 30 Sep 2001 04:06:20 +0900
"Ishigami Satoshi" <sishigam / hotmail.com> wrote:
> /cygdrive/c/usr/local/lib/ruby/1.6/open3.rb:22: stream closed (IOError)

stream closed (IOError)は1.7だと出なかったので、
1.6.5のバグっぽい気がします。

後ろにつけたようにopen3.rbを変更していろいろ試していたら
io.close unless io.closed?
でもstream closed (IOError)になったので。


% cat server.rb
require 'drb/drb'
require 'open3'

class Command
    def run(cmd)
        Open3.popen3(cmd)
    end
end

DRb.start_service("druby://localhost:4000", Command.new)
puts DRb.uri
puts '[return] to exit'
gets
% cat client.rb
require 'drb/drb'
DRb.start_service
cmd = DRbObject.new(nil, "druby://localhost:4000")
io = cmd.run("hostname")
p io[1].gets
%


サーバが1.7の時。
% ruby -v server.rb
ruby 1.7.1 (2001-09-20) [i586-linux]
druby://localhost:4000
[return] to exit

クライアント側
% ruby -v client.rb
ruby 1.6.5 (2001-09-19) [i386-linux]
"hoge\n"

サーバが1.6.5の時。
% ruby -v server.rb
ruby 1.6.5 (2001-09-19) [i386-linux]
druby://localhost:4000
[return] to exit
/usr/lib/ruby/1.6/open3.rb:20: stream closed (IOError)

クライアント側
% ruby -v client.rb
ruby 1.6.5 (2001-09-19) [i386-linux]
nil



-- 
|ZnZ(ゼット エヌ ゼット)
|西山和広(Kazuhiro NISHIYAMA)


--- open3.rb    2001/07/02 08:43:29     1.6.2.3
+++ open3.rb    2001/10/01 21:13:38
@@ -18,17 +18,19 @@
       # child
       fork{
        # grandchild
-       pw[1].close
+       Thread.critical = true
+       ObjectSpace.each_object(IO) {|io|
+         unless [STDIN,STDOUT,STDERR,pw[0],pr[1],pe[1]].include? io
+           begin
+             io.close unless io.closed?
+           rescue
+             p $!, io
+           end
+         end
+       }
        STDIN.reopen(pw[0])
-       pw[0].close
-
-       pr[0].close
        STDOUT.reopen(pr[1])
-       pr[1].close
-
-       pe[0].close
        STDERR.reopen(pe[1])
-       pe[1].close

        exec(*cmd)
       }