summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/win32/win32.c b/win32/win32.c
index bd4aa3ce30..7f46622dd5 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -5028,6 +5028,7 @@ rb_w32_read(int fd, void *buf, size_t size)
size_t len;
size_t ret;
OVERLAPPED ol, *pol = NULL;
+ int start = 0;
if (is_socket(sock))
return rb_w32_recv(fd, buf, size, 0);
@@ -5050,8 +5051,17 @@ rb_w32_read(int fd, void *buf, size_t size)
ret = 0;
retry:
- /* get rid of console writing bug */
- len = (_osfile(fd) & FDEV) ? min(16 * 1024, size) : size;
+ /* get rid of console reading bug */
+ if (is_console(_osfhnd(fd))) {
+ if (start)
+ len = min(16 * 1024, size);
+ else {
+ len = 0;
+ start = 1;
+ }
+ }
+ else
+ len = size;
size -= len;
/* if have cancel_io, use Overlapped I/O */