On 06/09/2014 05:11 PM, Pádraig Brady wrote:
> On 06/09/2014 04:16 PM, Michael Goffioul wrote:
>> See the following threads, with problem reporting and solution testing:
>> http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00092.html
>> http://lists.gnu.org/archive/html/bug-gnulib/2013-01/msg00007.html
> 
> Thanks for the defails and double follow up Micheal.
> I'll apply the attached later.

Actually there were a couple more instances of that.
I'll apply the attached later.

thanks,
Pádraig.
>From 7ca958fe6d1133051f776c0866ac2b93d69191f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Tue, 10 Jun 2014 23:31:39 +0100
Subject: [PATCH] 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.
---
 ChangeLog    |    7 +++++++
 lib/poll.c   |    8 +++++---
 lib/select.c |    8 +++++---
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fbb05bd..30ef195 100644
--- 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-09  Michael Goffioul  <michael.goffi...@gmail.com>
 
 	isatty: fix to work on windows 8
diff --git a/lib/poll.c b/lib/poll.c
index e9e9eb9..a3e0ab7 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -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)
diff --git a/lib/select.c b/lib/select.c
index a12f372..acb67a0 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -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)
-- 
1.7.7.6

Reply via email to