From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96167 invoked by alias); 2 Mar 2020 16:06:36 -0000 Mailing-List: contact cygwin-cvs-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-cvs-owner@cygwin.com Received: (qmail 96126 invoked by uid 9078); 2 Mar 2020 16:06:36 -0000 Date: Mon, 02 Mar 2020 16:06:00 -0000 Message-ID: <20200302160636.96124.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: ioctl: TIOCINQ: always return number of chars in the inbound queue X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: cef36220f247e02847ee4f39790b7debcc50a36b X-Git-Newrev: 1b7fcf22bea529fba920310dcd2db144bb24ccc6 X-SW-Source: 2020-q1/txt/msg00096.txt https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=1b7fcf22bea529fba920310dcd2db144bb24ccc6 commit 1b7fcf22bea529fba920310dcd2db144bb24ccc6 Author: Corinna Vinschen Date: Mon Mar 2 17:02:51 2020 +0100 Cygwin: ioctl: TIOCINQ: always return number of chars in the inbound queue So far ioctl(TIOCINQ) could end up returning -1 with errno set to EINVAL if a non-zero device error mask has been returned by ClearCommError. This doesn't reflect Linux behaviour, which always returns the number of chars in the inbound queue, independent of any I/O error condition. EINVAL was a pretty weird error code to use in this scenario, too. Fix this by dropping all checking for device errors in the TIOCINQ case. Just return the number of chars in the inbound queue. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/fhandler_serial.cc | 9 +-------- winsup/cygwin/release/3.1.5 | 3 +++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc index 615b251..69e5768 100644 --- a/winsup/cygwin/fhandler_serial.cc +++ b/winsup/cygwin/fhandler_serial.cc @@ -519,14 +519,7 @@ fhandler_serial::ioctl (unsigned int cmd, void *buf) } break; case TIOCINQ: - if (ev & CE_FRAME || ev & CE_IOE || ev & CE_OVERRUN || ev & CE_RXOVER - || ev & CE_RXPARITY) - { - set_errno (EINVAL); /* FIXME: Use correct errno */ - res = -1; - } - else - ipbuf = st.cbInQue; + ipbuf = st.cbInQue; break; case TIOCGWINSZ: ((struct winsize *) buf)->ws_row = 0; diff --git a/winsup/cygwin/release/3.1.5 b/winsup/cygwin/release/3.1.5 index e34fdb8..e567ecb 100644 --- a/winsup/cygwin/release/3.1.5 +++ b/winsup/cygwin/release/3.1.5 @@ -9,3 +9,6 @@ Bug Fixes: - Fix a segfault when starting, e.g., mintty from a bash in a console running xterm emulation. Addresses: https://cygwin.com/ml/cygwin/2020-02/msg00197.html + +- Fix TIOCINQ to always return number of inbound chars if available. + Addresses: https://cygwin.com/ml/cygwin/2020-02/msg00258.html