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 | |
parent | 1a7ce5850576e4046068195058e693b602add674 (diff) | |
download | newlib-b2be3149b474c01f52851b630cd58941060edd4d.zip newlib-b2be3149b474c01f52851b630cd58941060edd4d.tar.gz newlib-b2be3149b474c01f52851b630cd58941060edd4d.tar.bz2 |
* 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.
-rw-r--r-- | winsup/cygwin/ChangeLog | 9 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_termios.cc | 7 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 57 |
3 files changed, 42 insertions, 31 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 4a5bf42..f0015a1 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2002-12-16 Steve Osborn <bub@io.com> + Christopher Faylor <cgf@redhat.com> + + * 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. + 2002-12-16 Christopher Faylor <cgf@redhat.com> * pinfo.cc (_pinfo::cmdline): Allocate sufficient space for myself diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc index 16a826b..e6a1132 100644 --- a/winsup/cygwin/fhandler_termios.cc +++ b/winsup/cygwin/fhandler_termios.cc @@ -326,7 +326,12 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept) put_readahead (c); if (!iscanon || always_accept || input_done) { - (void) accept_input(); + if (!accept_input ()) + { + ret = line_edit_error; + eat_readahead (1); + break; + } ret = line_edit_input_done; input_done = 0; } diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 60918f6..f5f0c79 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 |