summaryrefslogtreecommitdiff
path: root/ext/io/console
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-14 14:21:46 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-14 14:21:46 +0900
commit456586bb234915107da255d2944f620a7dd7048b (patch)
treedb6ae90d674e537b6a16d3fab735ef2dd2377f6d /ext/io/console
parent6d733565c2df1b34c7f0b7d43d97f80f714a64b9 (diff)
io/console: support getch timeout on Windows
Diffstat (limited to 'ext/io/console')
-rw-r--r--ext/io/console/console.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index 0df67257d8b..2d63c1bfda7 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -419,7 +419,15 @@ console_getch(int argc, VALUE *argv, VALUE io)
GetOpenFile(io, fptr);
if (optp) {
- rb_warning("option ignored");
+ struct timeval *to = NULL, tv;
+ if (optp->vtime) {
+ to = &tv;
+ tv.tv_sec = optp->vtime / 10;
+ tv.tv_usec = (optp->vtime % 10) * 100000;
+ }
+ if (optp->vmin) {
+ rb_warning("min option ignored");
+ }
}
w = rb_wait_for_single_fd(fptr->fd, RB_WAITFD_IN, NULL);
if (w < 0) rb_eof_error();