Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2011-07-25 19:19:35 +0400
committerCorinna Vinschen <corinna@vinschen.de>2011-07-25 19:19:35 +0400
commitf4fc0c59e371d4d726e10745101431214b6e3c73 (patch)
tree1471216171b0936822b85a7d02d4954e9feaf5b7
parent7d4b10de8152823167722a3738c9d7ea7f10ef6b (diff)
* fhandler_console.cc (fhandler_console::ioctl): Fetch console events
using PeekConsoleInput and return only key down events in buf. * fhandler_tty.cc (fhandler_pty_slave::ioctl): Always return EINVAL if PeekNamedPipe fails. (fhandler_pty_master::ioctl): Ditto.
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/fhandler_console.cc14
-rw-r--r--winsup/cygwin/fhandler_tty.cc4
3 files changed, 21 insertions, 5 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 64e90be7b..f796ea3d1 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,11 @@
+2011-07-25 Corinna Vinschen <corinna@vinschen.de>
+
+ * fhandler_console.cc (fhandler_console::ioctl): Fetch console events
+ using PeekConsoleInput and return only key down events in buf.
+ * fhandler_tty.cc (fhandler_pty_slave::ioctl): Always return EINVAL
+ if PeekNamedPipe fails.
+ (fhandler_pty_master::ioctl): Ditto.
+
2011-07-22 Corinna Vinschen <corinna@vinschen.de>
* fhandler_tty.cc (fhandler_pty_slave::ioctl): Drop FIONBIO case.
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 4d2810203..5375721a1 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -892,13 +892,21 @@ fhandler_console::ioctl (unsigned int cmd, void *buf)
return -1;
case FIONREAD:
{
+ /* Per MSDN, max size of buffer required is below 64K. */
+#define INREC_SIZE (65536 / sizeof (INPUT_RECORD))
+
DWORD n;
- if (!GetNumberOfConsoleInputEvents (get_io_handle (), &n))
+ int ret = 0;
+ INPUT_RECORD inp[INREC_SIZE];
+ if (!PeekConsoleInputW (get_io_handle (), inp, INREC_SIZE, &n))
{
- __seterrno ();
+ set_errno (EINVAL);
return -1;
}
- *(int *) buf = (int) n;
+ while (n-- > 0)
+ if (inp[n].EventType == KEY_EVENT && inp[n].Event.KeyEvent.bKeyDown)
+ ++ret;
+ *(int *) buf = ret;
return 0;
}
break;
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 1d8d862ca..5236430cc 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -981,7 +981,7 @@ fhandler_pty_slave::ioctl (unsigned int cmd, void *arg)
int n;
if (!PeekNamedPipe (get_handle (), NULL, 0, NULL, (DWORD *) &n, NULL))
{
- __seterrno ();
+ set_errno (EINVAL);
retval = -1;
}
else
@@ -1381,7 +1381,7 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg)
int n;
if (!PeekNamedPipe (to_master, NULL, 0, NULL, (DWORD *) &n, NULL))
{
- __seterrno ();
+ set_errno (EINVAL);
return -1;
}
*(int *) arg = n;