PATCH: (sort of) RE: Possible bug with select and master side of pty

Christopher Faylor
Wed Nov 8 18:01:00 GMT 2000

On Wed, Nov 08, 2000 at 09:59:32PM +0300, Andrej Borsenkow wrote:
>> It may be a real problem and I appreciate your attempts to track it
>> down but since this seems to be working fine for the vast majority of
>> things which use the pty, I don't think I'll be fixing it any time soon.
>> If someone else would like to take a stab at this (hah?) that would be
>> swell.
>Attached is the half-hearted patch against 1.1.5-4 (relative to
>winsup/cygwin). The problem happens when someone reads from master side of pty
>using 1 byte buffer and onlcr is enabled. In this case read gets CR and
>appears to hang after that before it gets NL. It looks, like it "hangs" at the
>end of line. The same problem seems to be with select after CR was read - it
>thinks, no input is available.
>Forgive me my horrible c++; I still do not quite understand all these
>inheritance isuues. But the patch appears to work.

This patch looks pretty good and helped me enormously in understanding what
was going on.  After studying your patch and looking at the code a little,
I decided to go another way.

I just broke out the test in peek_pipe which was already checking for a pty
master and added the need_nl test there.  Your patch is more strictly correct
since it properly uses C++ inheritance to handle this rather than use an
if test but since the if test was already there, I decided to just go with
that (actually, I rewrote it to be a switch statement).

At some point, I'd like to use cygwin's typeahead handling for dealing
with this and get rid of the need_nl stuff.  At that point we would be
back to using the same peek_pipe function, so I'd rather not disturb
stuff too much right now.

Could you test out the patch below and let me know if it works for you?

This will be in tonight's snapshot and in the new cygwin 1.1.5-6 test

Thanks again for taking the time to track this down and develop a patch.
I really appreciate it.


Want to unsubscribe from this list?
Send a message to

More information about the Cygwin mailing list