diff options
author | Christopher Faylor <me@cgf.cx> | 2002-12-17 03:49:34 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-12-17 03:49:34 +0000 |
commit | b2be3149b474c01f52851b630cd58941060edd4d (patch) | |
tree | 7cfd6c957a91c7cbfce92c206a4342982a477d8e /winsup/cygwin/fhandler_tty.cc | |
parent | 1a7ce5850576e4046068195058e693b602add674 (diff) | |
download | cygnal-b2be3149b474c01f52851b630cd58941060edd4d.tar.gz cygnal-b2be3149b474c01f52851b630cd58941060edd4d.tar.bz2 cygnal-b2be3149b474c01f52851b630cd58941060edd4d.zip |
* fhandler_termios.cc (fhandler_termios::line_edit): Return line_edit_error and
remove last char from readahead buffer if accept_input() fails.
* fhandler_tty.cc (fhandler_pty_master::accept_input): Return 0 and restore
readahead buffer when tty slave pipe is full.
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 60918f6bd..f5f0c79e2 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -145,51 +145,48 @@ fhandler_pty_master::doecho (const void *str, DWORD len) int fhandler_pty_master::accept_input () { - DWORD bytes_left, written; - DWORD n; - DWORD rc; - char* p; + DWORD bytes_left; + int ret = 1; - rc = WaitForSingleObject (input_mutex, INFINITE); + (void) WaitForSingleObject (input_mutex, INFINITE); - bytes_left = n = eat_readahead (-1); - p = rabuf; + bytes_left = eat_readahead (-1); - if (n != 0) + if (!bytes_left) { - while (bytes_left > 0) - { - termios_printf ("about to write %d chars to slave", bytes_left); - rc = WriteFile (get_output_handle (), p, bytes_left, &written, NULL); - if (!rc) - { - debug_printf ("error writing to pipe %E"); - get_ttyp ()->read_retval = -1; - break; - } - else - get_ttyp ()->read_retval = 1; + termios_printf ("sending EOF to slave"); + get_ttyp ()->read_retval = 0; + } + else + { + char *p = rabuf; + DWORD rc; + DWORD written = 0; + termios_printf ("about to write %d chars to slave", bytes_left); + rc = WriteFile (get_output_handle (), p, bytes_left, &written, NULL); + if (!rc) + { + debug_printf ("error writing to pipe %E"); + get_ttyp ()->read_retval = -1; + } + else + { + get_ttyp ()->read_retval = 1; p += written; bytes_left -= written; if (bytes_left > 0) { debug_printf ("to_slave pipe is full"); - SetEvent (input_available_event); - ReleaseMutex (input_mutex); - Sleep (10); - rc = WaitForSingleObject (input_mutex, INFINITE); + puts_readahead (p, bytes_left); + ret = 0; } } } - else - { - termios_printf ("sending EOF to slave"); - get_ttyp ()->read_retval = 0; - } + SetEvent (input_available_event); ReleaseMutex (input_mutex); - return 1; + return ret; } static DWORD WINAPI |