From: nobu.nakada@... Date: 2002-05-20T12:47:59+09:00 Subject: [ruby-dev:17154] [PATCH] IO#clone for duplex IO なかだです。 なんでR/Wのパイプをdupしたのをclose_writeするとエラーになるのか、 不思議だったんですが、ここではまだfptr->f2はNULLのままです。 $ ruby-1.7 -ve 'f = open("|-") or sleep; f.dup.close_write' ruby 1.7.2 (2002-05-16) [i686-linux] -e:1:in `close_write': closing non-duplex IO for writing (IOError) from -e:1 $ ruby-1.6 -ve 'f = open("|-") or sleep; f.dup.close_write' ruby 1.6.7 (2002-05-16) [i686-linux] -e:1:in `close_write': closing non-duplex IO for writing (IOError) from -e:1 # 1.6でfileno()の重複をチェックしてないのが、socketでdupしなきゃ # いけない理由? 逆かな? Index: io.c =================================================================== RCS file: /cvs/ruby/src/ruby/io.c,v retrieving revision 1.137 diff -u -2 -p -r1.137 io.c --- io.c 2002/05/02 07:50:36 1.137 +++ io.c 2002/05/20 03:30:11 @@ -2228,5 +2228,5 @@ rb_io_clone(io) fd = ruby_dup(fileno(orig->f)); fptr->f = rb_fdopen(fd, mode); - if (fptr->f2) { + if (orig->f2) { if (fileno(orig->f) != fileno(orig->f2)) { fd = ruby_dup(fileno(orig->f2)); -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦