diff options
author | Egor Duda <deo@logos-m.ru> | 2001-03-18 21:05:01 +0300 |
---|---|---|
committer | Egor Duda <deo@logos-m.ru> | 2001-03-18 21:05:01 +0300 |
commit | 5e8e21d938b5410b008f20d50d8d0fb9ba6df66b (patch) | |
tree | 5d5ee41620a03a0049e82ceb0877685c09d29da1 /winsup/cygwin/fhandler_tty.cc | |
parent | ca1cea7ed3a1befe70787e8a7a3bfd81f9cb5899 (diff) |
* fhandler.h (fhandler_tty_slave): Declare new methods.
* select.cc (fhandler_tty_slave::select_read): New method.
* select.cc (fhandler_tty_slave::ready_for_read): Ditto.
* select.cc (verify_tty_slave): New function.
* fhandler_termios.cc (fhandler_termios::line_edit): Empty input
buffer on signal.
* fhandler_tty.cc (fhandler_tty_slave::read): Check for input data
after reading from pipe. Reset event if input pipe is empty.
* tty.h (class tty): Allow creating events with manual reset.
* tty.cc (tty::get_event): Use manual_reset flag.
* tty.cc (tty::common_init): Create input_available_event with
manual reset.
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 5cca97b4d..a2e815e66 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -614,6 +614,7 @@ fhandler_tty_slave::read (void *ptr, size_t len) size_t readlen; DWORD bytes_in_pipe; char buf[INP_BUFFER_SIZE]; + char peek_buf[INP_BUFFER_SIZE]; DWORD time_to_wait; DWORD rc; HANDLE w4[2]; @@ -667,7 +668,7 @@ fhandler_tty_slave::read (void *ptr, size_t len) termios_printf ("failed to acquire input mutex after input event arrived"); break; } - if (!PeekNamedPipe (get_handle (), NULL, 0, NULL, &bytes_in_pipe, NULL)) + if (!PeekNamedPipe (get_handle (), peek_buf, sizeof(peek_buf), &bytes_in_pipe, NULL, NULL)) { termios_printf ("PeekNamedPipe failed, %E"); _raise (SIGHUP); @@ -682,6 +683,16 @@ fhandler_tty_slave::read (void *ptr, size_t len) termios_printf ("read failed, %E"); _raise (SIGHUP); } + /* MSDN states that 5th prameter can be used to determine total + number of bytes in pipe, but for some reason this number doesn't + change after successful read. So we have to peek into the pipe + again to see if input is still available */ + if (!PeekNamedPipe (get_handle (), peek_buf, 1, &bytes_in_pipe, NULL, NULL)) + { + termios_printf ("PeekNamedPipe failed, %E"); + _raise (SIGHUP); + bytes_in_pipe = 0; + } if (n) { len -= n; @@ -691,8 +702,8 @@ fhandler_tty_slave::read (void *ptr, size_t len) } } - if (readlen != bytes_in_pipe) - SetEvent (input_available_event); + if (!bytes_in_pipe) + ResetEvent (input_available_event); ReleaseMutex (input_mutex); |