* 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.
This commit is contained in:
Egor Duda
2001-03-18 18:05:01 +00:00
parent ca1cea7ed3
commit 5e8e21d938
7 changed files with 83 additions and 7 deletions

View File

@ -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);