From: Motohiro KOSAKI Date: 2010-02-15T21:40:08+09:00 Subject: [ruby-dev:40428] [Bug #2747] io.dup doesn't handle pos properly チケット #2747 が更新されました。 (by Motohiro KOSAKI) 6の秘密はstraceが教えてくれている dup(4) = 5 lseek(4, 0, SEEK_CUR) = 0 lseek(5, 0, SEEK_SET) = 0 lseek(4, 0, SEEK_CUR) = 0 write(1, "0\n", 20 ) = 2 read(5, "1\n2\n3\n", 8192) = 6 write(1, "\"1\\n\"\n", 6"1\n" ) = 6 lseek(4, 0, SEEK_CUR) = 6 write(1, "6\n", 26 ) = 2 lseek(5, -4, SEEK_CUR) = 2 lseek(5, 0, SEEK_CUR) = 2 write(1, "2\n", 22 ) read(f2, buf, 8192)でバッファリング読み込みしたあと、オフセットを戻すのを忘れて lseek(f1, 0, SEEK_CUR) でposを読み込むのでファイル終端のposが得られている。 ---------------------------------------- http://redmine.ruby-lang.org/issues/show/2747 ---------------------------------------- http://redmine.ruby-lang.org