TIOCPKT mode of PTY is broken if ONLCR bit is cleared.

* tty.h (class tty_min): Remove variable "write_error" to which any
	errors are not currently set at anywhere.
	(class tty): Add variable "column" for handling ONOCR.
	* tty.cc (tty::init): Add initialization code for variable "column".
	* fhandler.h (class fhandler_pty_master): Remove variable "need_nl"
	which is not necessary any more. "need_nl" was needed by OPOST process
	in fhandler_pty_master::process_slave_output().
	(class fhandler_pty_common): Add function process_opost_output() for
	handling post processing for OPOST in write process.
	* fhandler_tty.cc (fhandler_pty_master::process_slave_output): Count
	TIOCPKT control byte into length to be read in TIOCPKT mode. Move
	post processing for OPOST to write process. Remove code related to
	variable "write_error". Return with EIO error if slave is already
	closed.
	(fhandler_pty_master::fhandler_pty_master): Remove initialization
	code for variable "need_nl".
	(fhandler_pty_common::process_opost_output): Add this function for
	handling of OPOST in write process. Add code to avoid blocking in
	non-blocking mode when output is suspended by ^S.
	(fhandler_pty_slave::write): Call fhandler_pty_common::
	process_opost_output() instead of WriteFile(). Remove code related to
	variable "write_error".
	(fhandler_pty_master::doecho): Call fhandler_pty_common::
	 process_opost_output() instead of WriteFile().
	* select.cc (peek_pipe): Remove code related to variable "need_nl".

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Takashi Yano
2015-03-25 20:42:38 +09:00
committed by Corinna Vinschen
parent d70f57112f
commit c596f5b73c
7 changed files with 168 additions and 132 deletions

View File

@ -1508,6 +1508,9 @@ class fhandler_pty_common: public fhandler_termios
copyto (fh);
return fh;
}
protected:
BOOL process_opost_output (HANDLE h, const void *ptr, ssize_t& len, bool is_echo);
};
class fhandler_pty_slave: public fhandler_pty_common
@ -1574,8 +1577,6 @@ class fhandler_pty_master: public fhandler_pty_common
DWORD dwProcessId; // Owner of master handles
public:
int need_nl; // Next read should start with \n
HANDLE get_echo_handle () const { return echo_r; }
/* Constructor */
fhandler_pty_master (int);