From: GOTOU Yuuzou Date: 2004-12-24T13:12:02+09:00 Subject: [ruby-dev:25302] test_readline.rb blocks on BSD again In message <20041223175402.3116FC6718@lithium.ruby-lang.org>, `nobu@ruby-lang.org (nobu)' wrote: > Log: > * io.c (io_reopen, rb_io_reopen): prohibit to change access mode for > special IO ports. [ruby-dev:25225] > 1.246.2.66 +34 -24 ruby/io.c > http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/io.c?cvsroot=src&r1=1.246.2.65&r2=1.246.2.66 調べ切れてないので報告だけですが、このコミットからNetBSDで test/readlineがうまく動かなくなっているようです。 $ ruby -e 'i=STDIN.dup;STDIN.reopen(open("/etc/hosts"));STDIN.reopen(i)' とすると、2回目のreopenで入力待ちになります。 # io.cを1.246.2.65に戻せば動きます。 % gdb ruby18 GNU gdb 5.3nb1 Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386--netbsdelf"... (gdb) r -e 'i=STDIN.dup;STDIN.reopen(open("/etc/hosts"));STDIN.reopen(i)' Starting program: /home/gotoyuzo/src/ruby/build-ruby18/ruby18 -e 'i=STDIN.dup;STDIN.reopen(open("/etc/hosts"));STDIN.reopen(i)' ^C Program received signal SIGINT, Interrupt. 0x481511c7 in read () from /usr/lib/libc.so.12 (gdb) info stack #0 0x481511c7 in read () from /usr/lib/libc.so.12 #1 0x481ceed5 in __sread () from /usr/lib/libc.so.12 #2 0x481bcf5d in __srefill () from /usr/lib/libc.so.12 #3 0x48183cdf in fseeko () from /usr/lib/libc.so.12 #4 0x4809ecac in io_reopen (io=134687144, nfile=134662484) at /home/gotoyuzo/src/ruby/ruby18/io.c:3220 #5 0x4809f093 in rb_io_reopen (argc=1, argv=0xbfbfdec0, file=134687144) at /home/gotoyuzo/src/ruby/ruby18/io.c:3279 #6 0x48090864 in call_cfunc (func=0x4809eeac , recv=134687144, len=-1, argc=1, argv=0xbfbfdec0) at /home/gotoyuzo/src/ruby/ruby18/eval.c:5384 #7 0x48084ef8 in rb_call0 (klass=134689624, recv=134687144, id=7161, oid=7161, argc=1, argv=0xbfbfdec0, body=0x8073100, nosuper=0) at /home/gotoyuzo/src/ruby/ruby18/eval.c:5522 #8 0x480856e3 in rb_call (klass=134689624, recv=134687144, mid=7161, argc=1, argv=0xbfbfdec0, scope=0) at /home/gotoyuzo/src/ruby/ruby18/eval.c:5743 #9 0x48080a18 in rb_eval (self=134724024, n=0x806c9f4) at /home/gotoyuzo/src/ruby/ruby18/ruby.h:631 #10 0x4807d170 in ruby_exec_internal () at /home/gotoyuzo/src/ruby/ruby18/eval.c:1473 #11 0x4807d1bd in ruby_exec () at /home/gotoyuzo/src/ruby/ruby18/eval.c:1493 #12 0x4807d1f0 in ruby_run () at /home/gotoyuzo/src/ruby/ruby18/eval.c:1503 #13 0x08048864 in main (argc=3, argv=0xbfbfe440, envp=0xbfbfe450) at /home/gotoyuzo/src/ruby/ruby18/main.c:46 #14 0x08048676 in ___start () (gdb) frame 4 #4 0x4809ecac in io_reopen (io=134687144, nfile=134662484) at /home/gotoyuzo/src/ruby/ruby18/io.c:3220 3220 io_seek(fptr, pos, SEEK_SET); (gdb) list 3215 } 3216 fptr->mode = m; 3217 } 3218 rb_thread_fd_close(fd); 3219 if ((orig->mode & FMODE_READABLE) && pos >= 0) { 3220 io_seek(fptr, pos, SEEK_SET); 3221 io_seek(orig, pos, SEEK_SET); 3222 } 3223 } 3224 (gdb) p orig->mode $2 = 65537 (gdb) p fptr->mode $3 = 65537 -- ごとうゆうぞう