diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | win32/win32.c | 4 |
2 files changed, 8 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Mon Nov 29 14:31:17 2010 NAKAMURA Usaku <usa@ruby-lang.org> + + * win32/win32.c (rb_w32_isatty): use GetConsoleMode() to determine the + fd is console or not, just like rb_w32_write_console(). + Mon Nov 29 14:19:40 2010 NAKAMURA Usaku <usa@ruby-lang.org> * include/ruby/win32.h (rb_w32_write_console): wrong prototype. diff --git a/win32/win32.c b/win32/win32.c index f55fe9c278..35cb686d1c 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -5576,11 +5576,13 @@ rb_w32_uchmod(const char *path, int mode) int rb_w32_isatty(int fd) { + DWORD mode; + // validate fd by using _get_osfhandle() because we cannot access _nhandle if (_get_osfhandle(fd) == -1) { return 0; } - if (!(_osfile(fd) & FDEV)) { + if (!GetConsoleMode((HANDLE)_osfhnd(fd), &mode)) { errno = ENOTTY; return 0; } |