diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2014-11-13 18:37:15 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2014-11-13 18:37:15 +0000 |
commit | 73742508fcd8e994450582c1b7296c709da66764 (patch) | |
tree | c405f5ab833dc3813d0d1b4d6b5aea57abbd713f /winsup/cygwin/fhandler_tty.cc | |
parent | d544f256d1c575f6358d6a9405f7906a5cfbce36 (diff) | |
download | cygnal-73742508fcd8e994450582c1b7296c709da66764.tar.gz cygnal-73742508fcd8e994450582c1b7296c709da66764.tar.bz2 cygnal-73742508fcd8e994450582c1b7296c709da66764.zip |
* fhandler.h (fhandler_termios::line_edit): Add parameter to return
written bytes.
* fhandler_termios.cc (fhandler_termios::tcinit): Fix formatting.
(fhandler_termios::line_edit): Return bytes actually written. Write
in 32 byte chunks in non-canonical mode to reduce number of WriteFile
calls. Don't just eat unwritten bytes in case of an error condition.
Especially, don't report them back to the caller as written.
* fhandler_tty.cc (fhandler_pty_slave::read): Disable code reducing
the number of bytes read from the pipe to vmin. Add comment.
(fhandler_pty_master::write): Convert ret to ssize_t type. Just call
line_edit once, not in a loop once for each byte. Return bytes written
as returned by line_edit.
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index eea635f89..25076810e 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -829,8 +829,13 @@ fhandler_pty_slave::read (void *ptr, size_t& len) readlen = MIN (bytes_in_pipe, MIN (len, sizeof (buf))); +#if 0 + /* Why on earth is the read length reduced to vmin, even if more bytes + are available *and* len is bigger *and* the local buf is big enough? + Disable this code for now, it looks like a remnant of old. */ if (ptr && vmin && readlen > (unsigned) vmin) readlen = vmin; +#endif DWORD n = 0; if (readlen) @@ -1330,7 +1335,7 @@ fhandler_pty_master::close () ssize_t __stdcall fhandler_pty_master::write (const void *ptr, size_t len) { - int i; + ssize_t ret; char *p = (char *) ptr; termios ti = tc ()->ti; @@ -1339,18 +1344,10 @@ fhandler_pty_master::write (const void *ptr, size_t len) return (ssize_t) bg; push_process_state process_state (PID_TTYOU); - - for (i = 0; i < (int) len; i++) - { - line_edit_status status = line_edit (p++, 1, ti); - if (status > line_edit_signalled) - { - if (status != line_edit_pipe_full) - i = -1; - break; - } - } - return i; + line_edit_status status = line_edit (p++, len, ti, &ret); + if (status > line_edit_signalled && status != line_edit_pipe_full) + ret = -1; + return ret; } void __reg3 |