diff options
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 034a5a018..dccbf13ea 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -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. */ @@ -664,7 +666,9 @@ fhandler_pty_slave::write (const void *ptr, size_t len) break; } - if (WriteFile (get_output_handle (), buf, n, &n, NULL) == FALSE) + DWORD res = WriteFile (get_output_handle (), buf, n, &n, NULL); + release_output_mutex (); + if (!res) { DWORD err = GetLastError (); termios_printf ("WriteFile failed, %E"); @@ -677,10 +681,10 @@ fhandler_pty_slave::write (const void *ptr, size_t len) } raise (SIGHUP); /* FIXME: Should this be SIGTTOU? */ towrite = (DWORD) -1; + release_output_mutex (); break; } } - release_output_mutex (); return towrite; } |