Project

General

Profile

Actions

Bug #3014

closed

select + read for STDIN unexpected result on Windows

Added by phasis68 (Heesob Park) about 14 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2dev (2010-03-26 trunk 27048) [i386-mswin32_90]
Backport:
[ruby-core:29018]

Description

=begin
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.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0