From 94660dd77f27e6f37d85dca2f54185cf7dffd4c0 Mon Sep 17 00:00:00 2001 From: Greg Najda Date: Sat, 6 Jul 2013 00:54:02 -0400 Subject: [PATCH] Improve detecting if a handle is a console on Windows. Use GetConsoleMode. If it succeeds (returns non-zero) then the handle is a console. If it fails (returns zero) then the handle is not a console. The old check, (GetFileType (handle) == FILE_TYPE_CHAR) assumes that a handle of type FILE_TYPE_CHAR is a console. This falsely reports a handle directed to NUL as a console. Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=12752 --- mono/metadata/console-win32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mono/metadata/console-win32.c b/mono/metadata/console-win32.c index 6b940f3edfb..7e0d598a282 100644 --- a/mono/metadata/console-win32.c +++ b/mono/metadata/console-win32.c @@ -46,7 +46,8 @@ ves_icall_System_ConsoleDriver_Isatty (HANDLE handle) { MONO_ARCH_SAVE_REGS; - return (GetFileType (handle) == FILE_TYPE_CHAR); + DWORD mode; + return GetConsoleMode (handle, &mode) != 0; } MonoBoolean -- 2.25.1