From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23386 invoked by alias); 12 Nov 2014 15:46:59 -0000 Mailing-List: contact cygwin-developers-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner@cygwin.com Mail-Followup-To: cygwin-developers@cygwin.com Received: (qmail 23341 invoked by uid 89); 12 Nov 2014 15:46:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: calimero.vinschen.de Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Nov 2014 15:46:57 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id C6E528E12EE; Wed, 12 Nov 2014 16:46:54 +0100 (CET) Date: Wed, 12 Nov 2014 15:46:00 -0000 From: Corinna Vinschen To: cygwin-developers@cygwin.com Subject: Re: Unexpected behavior using arrow keys on the terminal Message-ID: <20141112154654.GA2782@calimero.vinschen.de> Reply-To: cygwin-developers@cygwin.com Mail-Followup-To: cygwin-developers@cygwin.com References: <476974939.62973.1415788538204.JavaMail.yahoo@jws106102.mail.bf1.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bgVZo3zXaTQrZhjg" Content-Disposition: inline In-Reply-To: <476974939.62973.1415788538204.JavaMail.yahoo@jws106102.mail.bf1.yahoo.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2014-11/txt/msg00001.txt.bz2 --bgVZo3zXaTQrZhjg Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 2654 Hi George, On Nov 12 10:35, George Prekas wrote: > Using Cygwin 1.7.32, mintty 1.1.3 and OpenSSH_6.7p1 I am getting > unexpected behavior regarding the use of arrow keys on the terminal. > You can reproduce the behavior by doing the following: >=20 > ssh linux > cd /usr/src/linux/tools/perf > make > cd ~ > /usr/src/linux/tools/perf/perf record echo 42 > /usr/src/linux/tools/perf/perf report >=20 > Pressing UP or DOWN should highlight one of the rows displayed. You > can verify expected behavior by using either PuTTY or native Linux. >=20 > Observation #1: You can fix perf's behavior by applying perf.patch > (attached). >=20 > Observation #2: Using Wireshark, I've observed that when I ssh to a > host and press UP or DOWN on my terminal 3 packets are transmitted > from the client. PuTTY on the other hand transmits only 1 packet > (larger in size). >=20 > Observation #3: I wrote the program test.c (attached). If I run it and > press UP or DOWN: > * on Windows from cmd.exe it says "Read 3 bytes. First is 27." > * on Linux it says "Read 3 bytes. First is 27." > * on Linux via PuTTY it says "Read 3 bytes. First is 27." > * on Windows from mintty.exe it says "Read 1 bytes. First is 27. Read > 1 bytes. First is 91. Read 1 bytes. First is 65." >=20 > My understanding is that the unexpected behavior occurs because Cygwin > sends the UP/DOWN sequence one byte at a time. Specifically: >=20 > * winsup\cygwin\fhandler_tty.cc @ fhandler_pty_master::write > This is the function called by the write system call invoked by > mintty. Here len =3D 3. line_edit is invoked 3 times. > * winsup\cygwin\fhandler_termios.cc @ fhandler_termios::line_edit > This is called by the previous and it calls accept_input. > * winsup\cygwin\fhandler_tty.cc @ fhandler_pty_master::accept_input > This does the actual WriteFile to the pipe. >=20 > I would have provided a patch to fix the problem, but I am not sure I > completely understand the semantics of the above mentioned methods. I have to admit that I'm not quite sure either. In theory I'd say that the perf tool is making some invalid assumption here. You can't rely on a set of bytes sent from any input source to be always sent or received as a single package, unless you're working with a transport guaranteing this. Your analyzes of the underlying mechanism in Cygwin is correct, though. Despite what I said above, I take a look into this and perhaps I can fix the code to send more than 1 byte at a time.=20=20 Thanks, Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --bgVZo3zXaTQrZhjg Content-Type: application/pgp-signature Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJUY4DuAAoJEPU2Bp2uRE+gT2UQAJa7GArPKx3II/SmzYlfyAnR kKY6h8TBj69h+4EFso2RUX2/YlnvAiZ4GTpfrW0ctnHxveYaQTjhyGBUpUHMj0eK JQRR5MdrWM3fDiMLXHIQ8OdXR91fSavcfdiZWGZ0WmIusGTndst22ZtxDm13L+CN 4wjFc8Q1kUAaBT6ACrkXms+kMr9lynUsb8VDIywKKcW3WaTo3MsJedLGydlxAz2U cfCGEByCKBRWz0np9aw/Og6YA/M9WnpgQsvEOU4V0Ez70ddAy3SYRsMGruvqytRd UTE1iq4GnFlgGDD2YvYlYtbN2PzAVbKL0S6PplhoFdg766jJblWjZCiuewy3eCVZ wbnyu6WembA/szjuFmEpqx8LwvwoFXuSQwst9GHR+u4n0JRewIjsooQ/fm6qNglk TAkk9nJkTRI5NRnnNYrVeRWLFgrkUuIT7jJQ1oaAFxJnMGXBWooa2yapdkiJz3qr 6ZGIlqKftMf5us0K68cEfcMn+IhPcQTNRqqoN1Nlldy8q/K0i4RPa6QEJA84lZeE c5ziL9oeDKd8RNgih6Ep9nO3R3B+VTARjLmypgWrZfIg0LXJW57ALlpmT69X9ekL lCbg7YO4dML+3gZ3bOFbHsJHH6FRo67FJAi0z17DzNu5zIxIiZ9XAhYoA+jOFJmK +FWzK+bZ/sNSfC9SDsr5 =k70P -----END PGP SIGNATURE----- --bgVZo3zXaTQrZhjg--