summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_tty.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r--winsup/cygwin/fhandler_tty.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 1145bd14f..1428a064e 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -53,7 +53,11 @@ fhandler_pty_slave::get_unit ()
bool
bytes_available (DWORD& n, HANDLE h)
{
- bool succeeded = PeekNamedPipe (h, NULL, 0, NULL, &n, NULL);
+ char buf[INP_BUFFER_SIZE];
+ /* Apparently need to pass in a dummy buffer to read a real "record" from
+ the pipe. So buf is used and then discarded just so we can see how many
+ bytes will be read by the next ReadFile(). */
+ bool succeeded = PeekNamedPipe (h, buf, sizeof (buf), &n, NULL, NULL);
if (!succeeded)
{
termios_printf ("PeekNamedPipe(%p) failed, %E", h);
@@ -1429,7 +1433,7 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg)
set_errno (EINVAL);
return -1;
}
- *(int *) arg = (DWORD) n;
+ *(int *) arg = (int) n;
}
break;
default: