summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_tty.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-09-07 16:23:51 +0000
committerChristopher Faylor <me@cgf.cx>2000-09-07 16:23:51 +0000
commit29ac7f89e36e5f5b46286cdbb5501bcea3ce2055 (patch)
tree53317078f39b909b63757eadca3cf80fdd654738 /winsup/cygwin/fhandler_tty.cc
parentc1644acb233ed749b28b4139604ab134cf1cd34c (diff)
downloadcygnal-29ac7f89e36e5f5b46286cdbb5501bcea3ce2055.tar.gz
cygnal-29ac7f89e36e5f5b46286cdbb5501bcea3ce2055.tar.bz2
cygnal-29ac7f89e36e5f5b46286cdbb5501bcea3ce2055.zip
Split out tty and shared_info stuff into their own headers and use throughout.
Include sys/termios.h for files which need it. * tty.h: New file. * shared_info.h: New file. * fhandler.h: Move inline methods that rely on tty stuff to fhandler_console.cc. * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Set output_done_event immediately after reading data to speed up tty output processing. (process_output): Set write_error to errno or zero. (fhandler_tty_slave::write): Check previous write error prior to writing to slave end of pipe. This allows tty output to be slightly less synchronous. * fhandler_console.cc (fhandler_console::tcsetpgrp): Moved here from fhandler.h. (fhandler_console::set_input_state): Ditto.
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r--winsup/cygwin/fhandler_tty.cc39
1 files changed, 18 insertions, 21 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 6c7e3605e..c78f2bad6 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -23,6 +23,8 @@ details. */
#include "sigproc.h"
#include "pinfo.h"
#include "cygheap.h"
+#include "tty.h"
+#include "shared_info.h"
/* Tty master stuff */
@@ -285,14 +287,12 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on
}
termios_printf ("bytes read %u", n);
+ get_ttyp ()->write_error = 0;
+ if (output_done_event != NULL)
+ SetEvent (output_done_event);
if (get_ttyp ()->ti.c_lflag & FLUSHO)
- {
- get_ttyp ()->write_retval = n;
- if (output_done_event != NULL)
- SetEvent (output_done_event);
- continue;
- }
+ continue;
char *optr;
optr = buf;
@@ -389,8 +389,7 @@ process_output (void *)
ExitThread (0);
}
n = tty_master->console->write ((void *) buf, (size_t) n);
- tty_master->get_ttyp ()->write_retval = n == -1 ? -get_errno () : n;
- SetEvent (tty_master->output_done_event);
+ tty_master->get_ttyp ()->write_error = n == -1 ? get_errno () : 0;
}
}
@@ -554,6 +553,16 @@ fhandler_tty_slave::write (const void *ptr, size_t len)
ptr = (char *) ptr + n;
len -= n;
+ /* Previous write may have set write_error to != 0. Check it here.
+ This is less than optimal, but the alternative slows down tty
+ writes enormously. */
+ if (get_ttyp ()->write_error)
+ {
+ set_errno (get_ttyp ()->write_error);
+ towrite = (DWORD) -1;
+ break;
+ }
+
if (WriteFile (get_output_handle (), buf, n, &n, NULL) == FALSE)
{
DWORD err = GetLastError ();
@@ -577,13 +586,6 @@ fhandler_tty_slave::write (const void *ptr, size_t len)
rc = WaitForSingleObject (output_done_event, x);
termios_printf("waited %d ms for output_done_event, WFSO %d", x, rc);
}
-
- if (get_ttyp ()->write_retval < 0)
- {
- set_errno (-get_ttyp ()->write_retval);
- towrite = (DWORD) -1;
- break;
- }
}
release_output_mutex ();
return towrite;
@@ -931,12 +933,7 @@ fhandler_pty_master::write (const void *ptr, size_t len)
int
fhandler_pty_master::read (void *ptr, size_t len)
{
- int x = process_slave_output ((char *) ptr, len, pktmode);
-
- if (output_done_event != NULL)
- SetEvent (output_done_event);
-
- return x;
+ return process_slave_output ((char *) ptr, len, pktmode);
}
int