changeset 17702:77be5ed9d74f

select,poll: fix console handle check on windows 8 Similarly to commit a008d625 which fixed the obvious problem with isatty(), also apply the fix to the select() and poll() MS-Windows implementations. lib/poll.c (IsConsoleHandle): Change from testing the lower 2 bits of the handle to the more expensive but accurate syscall. lib/select.c: Likewise.
author Pádraig Brady <P@draigBrady.com>
date Tue, 10 Jun 2014 23:31:39 +0100
parents e41f2cd61471
children ba9e9026f860
files ChangeLog lib/poll.c lib/select.c
diffstat 3 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Jun 10 22:19:13 2014 +0100
+++ b/ChangeLog	Tue Jun 10 23:31:39 2014 +0100
@@ -1,3 +1,10 @@
+2014-06-10  Pádraig Brady  <P@draigBrady.com>
+
+	select,poll: fix console handle check on windows 8
+	lib/poll.c (IsConsoleHandle): Change from testing the lower
+	2 bits of the handle to the more expensive but accurate syscall.
+	lib/select.c: Likewise.
+
 2014-06-10  Eli Zaretskii  <eliz@gnu.org>
 
 	select: fix waiting on anonymous pipes on MS-Windows
--- a/lib/poll.c	Tue Jun 10 22:19:13 2014 +0100
+++ b/lib/poll.c	Tue Jun 10 23:31:39 2014 +0100
@@ -70,9 +70,11 @@
 
 #ifdef WINDOWS_NATIVE
 
-/* Optimized test whether a HANDLE refers to a console.
-   See <http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00065.html>.  */
-#define IsConsoleHandle(h) (((intptr_t) (h) & 3) == 3)
+static BOOL IsConsoleHandle (HANDLE h)
+{
+  DWORD mode;
+  return GetConsoleMode (h, &mode) != 0;
+}
 
 static BOOL
 IsSocketHandle (HANDLE h)
--- a/lib/select.c	Tue Jun 10 22:19:13 2014 +0100
+++ b/lib/select.c	Tue Jun 10 23:31:39 2014 +0100
@@ -82,9 +82,11 @@
 #define PIPE_BUF        512
 #endif
 
-/* Optimized test whether a HANDLE refers to a console.
-   See <http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00065.html>.  */
-#define IsConsoleHandle(h) (((intptr_t) (h) & 3) == 3)
+static BOOL IsConsoleHandle (HANDLE h)
+{
+  DWORD mode;
+  return GetConsoleMode (h, &mode) != 0;
+}
 
 static BOOL
 IsSocketHandle (HANDLE h)