diff options
author | Egor Duda <deo@logos-m.ru> | 2001-04-27 10:27:28 +0400 |
---|---|---|
committer | Egor Duda <deo@logos-m.ru> | 2001-04-27 10:27:28 +0400 |
commit | a069f5602ee213504a1e8f42048d2fc39b3126c3 (patch) | |
tree | 940973f80ae6cc80fa1a5c2ab82e3736bcdf4268 /winsup/cygwin/fhandler_tty.cc | |
parent | 22ae5a5be8eeef5722e003ccf07b133a59018b66 (diff) |
* tty.cc (tty::make_pipes): Set to_slave pipe mode to nonblocking.
* fhandler_tty.cc (fhandler_pty_master::accept_input): If pipe buffer
is full, give slave a chance to read data.
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index e33d1d31b..acb10a93d 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -167,18 +167,40 @@ fhandler_pty_master::doecho (const void *str, DWORD len) int fhandler_pty_master::accept_input () { - DWORD written; + DWORD bytes_left, written; DWORD n; DWORD rc; + char* p; rc = WaitForSingleObject (input_mutex, INFINITE); - n = get_ttyp ()->read_retval = eat_readahead (-1); + bytes_left = n = eat_readahead (-1); + get_ttyp ()->read_retval = 0; + p = rabuf; if (n != 0) { - termios_printf ("about to write %d chars to slave", n); - rc = WriteFile (get_output_handle (), rabuf, n, &written, NULL); + 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"); + break; + } + get_ttyp ()->read_retval += written; + 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); + } + } } else termios_printf ("sending EOF to slave"); |