From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19081 invoked by alias); 12 Nov 2014 10:35:44 -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 19067 invoked by uid 89); 12 Nov 2014 10:35:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.4 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: nm2-vm1.bullet.mail.bf1.yahoo.com Received: from nm2-vm1.bullet.mail.bf1.yahoo.com (HELO nm2-vm1.bullet.mail.bf1.yahoo.com) (98.139.213.158) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 12 Nov 2014 10:35:41 +0000 Received: from [66.196.81.171] by nm2.bullet.mail.bf1.yahoo.com with NNFMP; 12 Nov 2014 10:35:39 -0000 Received: from [98.139.212.196] by tm17.bullet.mail.bf1.yahoo.com with NNFMP; 12 Nov 2014 10:35:39 -0000 Received: from [127.0.0.1] by omp1005.mail.bf1.yahoo.com with NNFMP; 12 Nov 2014 10:35:38 -0000 Received: by 66.196.81.115; Wed, 12 Nov 2014 10:35:38 +0000 Date: Wed, 12 Nov 2014 10:35:00 -0000 From: George Prekas Reply-To: George Prekas To: "cygwin-developers@cygwin.com" Message-ID: <476974939.62973.1415788538204.JavaMail.yahoo@jws106102.mail.bf1.yahoo.com> Subject: Unexpected behavior using arrow keys on the terminal MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_62972_1756478879.1415788538204" X-SW-Source: 2014-11/txt/msg00000.txt.bz2 ------=_Part_62972_1756478879.1415788538204 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 2074 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: 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 Pressing UP or DOWN should highlight one of the rows displayed. You can verify expected behavior by using either PuTTY or native Linux. Observation #1: You can fix perf's behavior by applying perf.patch (attached). 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). 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." My understanding is that the unexpected behavior occurs because Cygwin sends the UP/DOWN sequence one byte at a time. Specifically: * winsup\cygwin\fhandler_tty.cc @ fhandler_pty_master::write This is the function called by the write system call invoked by mintty. Here len = 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. 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. Regards, George Prekas Dipl. Electrical and Computer Engineer, National Technical University of Athens P.S. To be honest, I am not sure how much unexpected is this behavior. I just thought it would be good to have a bug report for it. ------=_Part_62972_1756478879.1415788538204 Content-Type: text/x-diff Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=perf.patch Content-ID: <2621618f-d97d-558a-6d38-1e39441e17c6@yahoo.com> Content-length: 570 ZGlmZiAtLWdpdCBhL3Rvb2xzL3BlcmYvdWkvdHVpL3NldHVwLmMgYi90b29s cy9wZXJmL3VpL3R1aS9zZXR1cC5jCmluZGV4IDJmNjEyNTYuLjEzNWVkNjkg MTAwNjQ0Ci0tLSBhL3Rvb2xzL3BlcmYvdWkvdHVpL3NldHVwLmMKKysrIGIv dG9vbHMvcGVyZi91aS90dWkvc2V0dXAuYwpAQCAtNzksNyArNzksNyBAQCBp bnQgdWlfX2dldGNoKGludCBkZWxheV9zZWNzKQogCUZEX1pFUk8oJnJlYWRf c2V0KTsKIAlGRF9TRVQoMCwgJnJlYWRfc2V0KTsKIAl0aW1lb3V0LnR2X3Nl YyA9IDA7Ci0JdGltZW91dC50dl91c2VjID0gMjA7CisJdGltZW91dC50dl91 c2VjID0gNTAwOwogICAgICAgICBlcnIgPSBzZWxlY3QoMSwgJnJlYWRfc2V0 LCBOVUxMLCBOVUxMLCAmdGltZW91dCk7CiAJaWYgKGVyciA9PSAwKQogCQly ZXR1cm4gS19FU0M7Cg== ------=_Part_62972_1756478879.1415788538204 Content-Type: text/x-csrc Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=test.c Content-ID: <8f5d4a94-a194-b9b9-5bb4-f994d60d0124@yahoo.com> Content-length: 415 I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDx0ZXJtaW9zLmg+CgppbnQg bWFpbigpIHsKICBzdHJ1Y3QgdGVybWlvcyB0aW87CiAgY2hhciBidWZbMTZd OwogIGludCBsZW47CgogIHRjZ2V0YXR0cigwLCZ0aW8pOwogIHRpby5jX2xm bGFnICY9KH5JQ0FOT04gJiB+RUNITyk7CiAgdGNzZXRhdHRyKDAsVENTQU5P VywmdGlvKTsKCiAgd2hpbGUgKDEpIHsKICAgIGxlbiA9IHJlYWQoMCwgYnVm LCBzaXplb2YoYnVmKSk7CiAgICBwcmludGYoIlJlYWQgJWQgYnl0ZXMuIEZp cnN0IGlzICVkLlxuIiwgbGVuLCBidWZbMF0pOwogIH0KfQo= ------=_Part_62972_1756478879.1415788538204--