diff options
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index c5b65c5b8..6bb389f38 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -91,7 +91,7 @@ static int osi; void fhandler_pty_master::flush_to_slave () -{ +{ if (get_readahead_valid () && !(get_ttyp ()->ti.c_lflag & ICANON)) accept_input (); } @@ -281,7 +281,7 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on goto out; } pthread_testcancel (); - if (cancelable_wait (NULL, 10, cw_sig_eintr) == WAIT_SIGNALED + if (cygwait (NULL, 10, cw_sig_eintr) == WAIT_SIGNALED && !_my_tls.call_signal_handler ()) { set_errno (EINTR); @@ -645,8 +645,6 @@ fhandler_pty_slave::write (const void *ptr, size_t len) push_process_state process_state (PID_TTYOU); - acquire_output_mutex (INFINITE); - while (len) { n = MIN (OUT_BUFFER_SIZE, len); @@ -654,6 +652,10 @@ fhandler_pty_slave::write (const void *ptr, size_t len) ptr = (char *) ptr + n; len -= n; + while (tc ()->output_stopped) + cygwait (10); + acquire_output_mutex (INFINITE); + /* Previous write may have set write_error to != 0. Check it here. This is less than optimal, but the alternative slows down pty writes enormously. */ @@ -661,10 +663,14 @@ fhandler_pty_slave::write (const void *ptr, size_t len) { set_errno (get_ttyp ()->write_error); towrite = (DWORD) -1; + get_ttyp ()->write_error = 0; + release_output_mutex (); break; } - if (WriteFile (get_output_handle (), buf, n, &n, NULL) == FALSE) + BOOL res = WriteFile (get_output_handle (), buf, n, &n, NULL); + release_output_mutex (); + if (!res) { DWORD err = GetLastError (); termios_printf ("WriteFile failed, %E"); @@ -680,7 +686,6 @@ fhandler_pty_slave::write (const void *ptr, size_t len) break; } } - release_output_mutex (); return towrite; } |