From 5bd144c1bb20e22e4d9f5e5e0264820fd3ef8137 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 22 Nov 2024 14:29:47 +0900 Subject: [PATCH] Add a temporal debugging code ... to check the return value of ioctl http://ci.rvm.jp/results/trunk_asan@ruby-sp1/5423172 ``` /tmp/ruby/src/trunk_asan/lib/reline/io/ansi.rb:192: [BUG] rb_sys_fail_str() - errno == 0 ``` --- ext/io/console/console.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ext/io/console/console.c b/ext/io/console/console.c index 77c5c695a1..98296c85d3 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -824,7 +824,14 @@ console_winsize(VALUE io) { rb_console_size_t ws; int fd = GetWriteFD(io); +#if defined TIOCGWINSZ + // temporal debugging code + int ret = ioctl(fd, TIOCGWINSZ, &ws); + if (ret == -1) sys_fail(io); + if (ret != 0) rb_bug("ioctl(TIOCGWINSZ) returned %d", ret); +#else if (!getwinsize(fd, &ws)) sys_fail(io); +#endif return rb_assoc_new(INT2NUM(winsize_row(&ws)), INT2NUM(winsize_col(&ws))); }