From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12660 invoked by alias); 27 Feb 2020 21:39:00 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 12629 invoked by uid 89); 27 Feb 2020 21:39:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=troubles, HX-Languages-Length:1015, H*u:6.1, HContent-Transfer-Encoding:8bit X-HELO: mail-lj1-f182.google.com Received: from mail-lj1-f182.google.com (HELO mail-lj1-f182.google.com) (209.85.208.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Feb 2020 21:38:59 +0000 Received: by mail-lj1-f182.google.com with SMTP id q8so892819ljj.11 for ; Thu, 27 Feb 2020 13:38:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=XgcuY4dTosJyfOvySPyQIxjceVy+qYYl/JMUbhwx+Lc=; b=nA12YMSr71Sg+/KJyMvnlzHx6/k9eBQquxFFhMZMz2Z9UnTJ2dArFH726cMZayFI4i 6T8mkHlfe0rvV7c0v2kvW8OFH+8aGVAgkWU8WKe9Y6MFliQCmqM+ihGZQk4mv6esNZw6 xM91SabA+Z06YpAE+ztaZw7SyzVS15Y9UvWVuAMEDRklX5g7h1tTz2dJsg/v0xfPFjdi dvqJBXNch+FU8b4RXPa/ku5u7tZocr2bt11tKBXLiYJOlzrAWYu/Kxn9X3TezGNDYPGH y552ANJogAfqXsOboHptxo4KqKq5o7Kq9cWR+rcVhSwjCkhEg1RGbD+DSvDYbc+ZSl2J O8IQ== Return-Path: Received: from [192.168.1.117] (tb213-185-244-58.cust.teknikbyran.com. [213.185.244.58]) by smtp.googlemail.com with ESMTPSA id r25sm3928326lfn.36.2020.02.27.13.38.55 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Feb 2020 13:38:55 -0800 (PST) To: cygwin@cygwin.com From: =?UTF-8?Q?=c3=85ke_Rehnman?= Subject: Incorrect behavior in TIOCINQ ioctl Message-ID: Date: Thu, 27 Feb 2020 21:39:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00258.txt.bz2 Hi, I recently ran in to some troubles with the TIOCINQ ioctl. I am wondering if the cygwin implementation is correct... It seems if there were any existing framing overrun errors etc etc  before calling the TIOCINQ ioctl it is returning an error (EINVAL). Reading through linux implmentation of TIOCINQ does simply return number of pending chars without any clearing or checking for errors. I suggest the whole if (ev & CE_FRAME  ...... ) is removed. Excerpt from fhandler_serial.cc: /* ioctl: */ int fhandler_serial::ioctl (unsigned int cmd, void *buf) { . .   if (!ClearCommError (get_handle (), &ev, &st))     {       __seterrno ();       res = -1;     } . . .      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;      break; -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple