]> Savannah Git Hosting - gnulib.git/commitdiff
select,poll: fix console handle check on windows 8
authorPádraig Brady <P@draigBrady.com>
Tue, 10 Jun 2014 22:31:39 +0000 (23:31 +0100)
committerPádraig Brady <P@draigBrady.com>
Wed, 11 Jun 2014 10:06:49 +0000 (11:06 +0100)
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.

ChangeLog
lib/poll.c
lib/select.c

index d2a42feb6ceb3e41c4329e82a7781b59f87d0b05..0e179b1367e613c3c092fac7c44af8e72985ea3e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index e9e9eb9cea68f6d0e13513ff97d7506406bb3b53..a3e0ab7e7d684fa3c5ff726b8201171aa4b11975 100644 (file)
 
 #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)
index a12f37288a88e39ad3833001e979984e343425c6..acb67a0e7041766daae1d1a90ac0e502f5811754 100644 (file)
@@ -82,9 +82,11 @@ typedef DWORD (WINAPI *PNtQueryInformationFile)
 #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)