delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/12/10/07:51:34

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=tCU+ZmAyheg7nEJNwlw5UVV+IMuGO42Nw2RGCWvF//roTXELpN3AE
ZNEu7LpGVHNsKqR6SiHEnVkHmKey6PCA1Al+lWQ02XtpagxecVtPxGKiZssAQX2r
82UKCjIUy3h0WYZ0lLW2384pVFtuwe3qKMEQSSR9PcycfbmgvRF3cU=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=FmqlUG7DGkkm6HEARyM3d60uI6E=; b=as/xb+w9Me7UV9ReEjUG4pPz5sk4
w2fK1elUrSGkwGFovv43vxoEWnklhxM8NLB8Gg9Upv61I9nvb+u0V+1Nx75Wm41v
uJWAfEqc7SUvDKGBPIZE30SQa1TKqP2W8P9tQRawY3pON37I1mOzgnA8Qvbcy/g/
urLV8KQiLlQHyes=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=AWL,BAYES_40 autolearn=ham version=3.3.2
X-HELO: calimero.vinschen.de
Date: Wed, 10 Dec 2014 13:51:03 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: select() fails on multi-byte input in cygwin console (since 1.7.10)
Message-ID: <20141210125103.GT3810@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <54869E93 DOT 60304 AT towo DOT net> <20141209111922 DOT GI3810 AT calimero DOT vinschen DOT de> <5487F053 DOT 3020003 AT towo DOT net>
MIME-Version: 1.0
In-Reply-To: <5487F053.3020003@towo.net>
User-Agent: Mutt/1.5.23 (2014-03-12)

--1FTutcXiQhqXqWGN
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Dec 10 08:03, Thomas Wolff wrote:
> Hi Corinna,
>=20
> Am 09.12.2014 um 12:19 schrieb Corinna Vinschen:
> >Hi Thomas,
> >
> >On Dec  9 08:02, Thomas Wolff wrote:
> >>Calling select() to check whether input from the terminal is available
> >>fails for all but the first byte in the cygwin console if multiple bytes
> >>are entered at once, like function or cursor keys or non-ASCII UTF-8
> >>characters.
> >>Actually, the issue is volatile, sometimes it works for characters and
> >>most function keys.
> >>The problem most likely arises with the escape sequences mouse scroll
> >>and window focus out/in (both enabled by the test program).
> >>I tried to use read() with timeout instead, trying various combinations
> >>of tcsetattr setting VMIN/VTIME, fcntl setting O_NONBLOCK, using read()
> >>with buffer length 0, trying to interrupt read() with a timer signal, or
> >>even a combination of setitimer() and siglongjmp().
> >>None of this works.
> >Your STC creates 0s and 1s, and it looks quite normal to me with the
> >latest from CVS.  Without a short description I don't know exactly what
> >to look out for.  There are lots of 0s, and if I press a cursor key
> >I see three 1s, one for each char of the escape sequence.
>=20
> I should have been more precise, and there are actually two slightly
> different effects (I noticed the first after my report): If you press
> a multi-byte key (like =C3=A4, =E2=82=AC, F1), only the first byte will b=
e seen by
> select() and echoed immediately by the test program. The remaining
> bytes will only appear after you have *released* the key (looking
> carefully before the keyboard auto-repeats...).

Uh, ok, now I saw it.

> Now, when you press a
> mouse key, the whole sequence appears, with the exception of mouse
> wheel scrolling or focus reports (click out then into the console
> window) - here only the first byte is seen until any other input.

I have no mouse wheel (good old 3-button mouse here :)) so I can't test
it, but the effect is clear now.

> >Did you try the latest snapshot or the 1.7.34-002 test release?  ...
> Yes, no change. (And yesterday's snapshot mentioned in some other
> thread is not yet visible.)
>=20
> >If that doesn't help, would you mind trying to track this down?  You're
> >familiar with Cygwin's console code so you might get a clue what's going
> >wrong.
>=20
> Partially familiar...

Same here.

> Since mouse escape sequences are all generated
> in the same way but there is a difference among them (the bug
> occurring with mouse scrolling and window focus switching), I'm afraid
> it's not simply the console code. I suspect there is some subtle
> interference between console code and Windows events (and I'm not
> familiar with Windows APIs).  I could at best try to find out which of
> the changes 1.7.9->1.7.10 made the issue appear.  We'll see...

Sure.  The switch from 1.7.9 to 1.7.10 is just long ago.  It doesn't
hurt to look, but it might not be that helpful to see the difference,
given the changes to the console code in the meantime.

You could also have a look into the affected select code, which is
basically the function peek_console in select.cc.  What I see there is
this:

  PeekConsoleInput (h, &irec, 1, &events_read)

checks if any one byte of input is available in the console(*) and
later:

  ReadConsoleInput (h, &irec, 1, &events_read);

so apparently it always reads(**) only one byte per select.

Maybe a bit of experimenting here would help?!?


Thanks,
Corinna


(*) http://msdn.microsoft.com/en-us/library/windows/desktop/ms684344%28v=3D=
vs.85%29.aspx
(**) http://msdn.microsoft.com/en-us/library/windows/desktop/ms684961%28v=
=3Dvs.85%29.aspx

--=20
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--1FTutcXiQhqXqWGN
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJUiEG3AAoJEPU2Bp2uRE+g5UAP/i7v7Z1Sx0qtly5CmVvB1m1M
vWE1EQjbwGkT5yx4ZQj48ynEK+Sdqpl+ZbiEUPTuc2ZsDnrFrsMTc3UeF/GRKsqz
WdaLOfO0/HAxM0uEHEFLDveHxHGLDAtnn1NgDtN0N2ACLelAebRh+hDTEYKYzCbR
fiyUgXVrCT+gfsjWrzqaxAGHPXXYWZLhv+v5pD3vL4Wx+LNJH+Zf6ShDLZURCoKV
FmK45WK6vj+DPpp8+CNvKlfltzA2gRNSAfdRM2AUt90fNvkubHh7HrkNI9FY+Dua
9MDifoUuWtOW3uv2Iic71+VSs35T3S55+1my88ctx4+pYn3vihcJBzmqjOEeVKxF
Ii4ooL1gP10Rs+VNABavjoaAgx1NEZPn+XkphfFQMv/9Kpbd9KUbee4K2gzhEAM0
+iDVnPJGMwH0C4wJuS9z3/4iYZ/7RYoJC18OqFvH68gungl75t/UXVOIJ9vKX7Hl
d4dW5DppzoZHOojSTV0Q45m40P8YaBzkwmHQ2rx675M2xU9hCsLwLUFJ9vIK2ax2
pyp1jmiRcukIRFiSZvXtGOfvSP5jlVVbFO5HQoDmcdIQn/fAeWGMgBPkNLbmGF1r
4YFf3gpg4SBJNBpTvKE5ObxPuzmSmJ8AQR02mpEySniIi4LJz/keQmK5O5OiHrfg
Dp4lWO9y52PtsCI+D3lX
=VXpX
-----END PGP SIGNATURE-----

--1FTutcXiQhqXqWGN--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019