Issue #3014 has been updated by Heesob Park.



I found that STDIN.read(n) works when n >= 41.

I guess this bug is caused by PeekConsoleInput's bug or side effect.

Here is a guick and dirty patch.


--- win32.c     2010-03-26 19:04:28.502025030 +0900
+++ win32.c.new 2010-03-26 19:03:05.138310126 +0900
@@ -4851,6 +4851,10 @@
        return _read(fd, buf, size);
     }

+    if((_osfile(fd) & FDEV) && size <= 40) {
+       return fread(buf, 1, size, stdin);
+    }
+
     MTHREAD_ONLY(EnterCriticalSection(&(_pioinfo(fd)->lock)));

     if (!size || _osfile(fd) & FEOFLAG) {


----------------------------------------
http://redmine.ruby-lang.org/issues/show/3014

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