Bug #3014: select + read for STDIN unexpected result on Windows
http://redmine.ruby-lang.org/issues/show/3014

Author: Heesob Park
Status: Open, Priority: Normal
Category: core, Target version: 1.9.x
ruby -v: ruby 1.9.2dev (2010-03-26 trunk 27048) [i386-mswin32_90]

I found that select and read combination for STDIN results "r u b y . e x e"  on Windows.

Consider following code:
select([STDIN],nil,nil,10);puts STDIN.read(8)

I entered "test1234\n" for input.

On 1.8.6, it works fine.

C:\>ruby -ve 'select([STDIN],nil,nil,10);puts STDIN.read(8)'
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]
test1234
test1234

On 1.9.x, it results "r u b y".

C:\work>ruby -ve 'select([STDIN],nil,nil,10);puts STDIN.read(8)'
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mingw32]
test1234
r u b y

C:\work>ruby -ve 'select([STDIN],nil,nil,10);puts STDIN.read(8)'
ruby 1.9.2dev (2010-03-26 trunk 27048) [i386-mswin32_90]
test1234
r u b y

C:\work>ruby -ve 'select([STDIN],nil,nil,10);p STDIN.read(8)'
ruby 1.9.2dev (2010-03-26 trunk 27048) [i386-mswin32_90]
test1234
"r\x00u\x00b\x00y\x00"

The result string is actually "r u b y . e x e" plus some garbage.


----------------------------------------
http://redmine.ruby-lang.org