This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin hangs up if several keys are typed during outputting a lot of texts.

Hi Corinna,

On Thu, 16 Apr 2015 11:05:33 +0200
Corinna Vinschen <> wrote:

> Ok, but... this is a really big patch and it complicates the pty code
> even more.  Is there really no other option as far as the TCSADRAIN
> problem is concerned?
> What strikes me as weird is that neither fhandler_pty_slave::tcsetattr
> nor fhandler_pty_master::tcsetattr give a damn for the optional_actions
> parameter.  They simply overwrite the tc settings.  So I'm wondering,
> wouldn't it be possible to add code to the tcsetattr implementation
> instead, so that TCSADRAIN/TCSAFLUSH are honored and than only have one
> place for OPOST handling?

I also think the patch was a big deal. However, I did not have
any other good idea.

Anyway, I have worked out another solution. Please find a patch

What do you think of this one?

OPOST code has been now completely moved back to master side as
with original implementation.

With this patch, tcsetattr() waits until master reads all data
in pipe before new attributes are applied to preserve the order
between write() and tcsetattr().

However, there is a potential risk in which tcsetattr() can be
blocked if master stops reading pipe, even though I can not imagine
such a likely situation.

Moreover, it is necessary to duplicate io_handle from master-side
to slave-side to allow slave to peek master pipe. It is not smart
enough, I suppose.

ChageLog is as follows.

2015-04-17  Takashi Yano  <>

	* fhandler.h (fhandler_pty_common): Remove function
	process_opost_output (). Since processing regarding OPOST is moved back
	to master side, this function is needed no more.
	(class fhandler_pty_slave): Add variable 'from_slave' for checking
	whether master input pipe is empty. This used by flandler_pty_slave
	(class fhandler_pty_master): Move variable 'column' for handling ONOCR
	from class tty to class fhandler_pty_master. Revive variable 'need_nl'
	which is used by OPOST-processing in master side.
	* (struct pipe_reply): Add member 'from_slave'.
	(fhandler_pty_master::doecho): Call WriteFile() instead of
	(fhandler_pty_master::process_slave_output): Move OPOST-processing back
	into this function.
	(fhandler_pty_slave::fhandler_pty_slave): Initialize 'from_slave'.
	(fhandler_pty_slave::open): Duplicate handle regarding 'from_slave'.
	(fhandler_pty_slave::close): Close handle 'from_slave'.
	(fhandler_pty_slave::write): Call WriteFile() instead of
	(fhandler_pty_slave::tcsetattr): Wait until master reads all data from
	(fhandler_pty_slave::fhandler_pty_slave): Initialize 'column' and
	(fhandler_pty_master::pty_master_thread): Add code to duplicate handle
	regarding 'from_slave'.
	(fhandler_pty_master::setup): Set io_handle to tty::_from_slave.
	(fhandler_pty_common::process_opost_output): Remove this function.
	* (peek_pipe): Revive the code checking 'need_nl'.
	* (tty::init): Remove initialization for 'column'.
	* tty.h (class tty): Add variable '_from_slave'. Add two functions
	from_slave() and set_from_slave() regarding '_from_master'. Remove
	variable 'column'. It is moved to class fhandler_pty_master.

Takashi Yano <>

Attachment: cygwin.patch.20150417-2
Description: Binary data

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]