summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_tty.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-10-12 01:19:04 +0000
committerChristopher Faylor <me@cgf.cx>2012-10-12 01:19:04 +0000
commitfe0cb311370003fc5839e592c79b460aa841a63b (patch)
treea0c503ba875c81831a4462a3992658bb668a440c /winsup/cygwin/fhandler_tty.cc
parent52985c1686253dbfe45756bdbefe9568ef401c4e (diff)
downloadcygnal-fe0cb311370003fc5839e592c79b460aa841a63b.tar.gz
cygnal-fe0cb311370003fc5839e592c79b460aa841a63b.tar.bz2
cygnal-fe0cb311370003fc5839e592c79b460aa841a63b.zip
* fhandler_termios.cc (fhandler_termios::line_edit): Don't manipulate
output_mutex on CTRL-S/CTRL-Q to avoid a deadlock. * fhandler_tty.cc (fhandler_pty_slave::write): Loop when output_stopped is detected before acquiring output_mutex. Acquire output_mutex in the loop for each write. * tty.h: Remove some obsolete defines. (tty_min::output_stopped): Make 'bool'.
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r--winsup/cygwin/fhandler_tty.cc12
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;
}