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:to:from:subject:message-id:date:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=UeN LbKJHuwxRnRe6Bvh24SvMfRxtAcMKaqvKuEhjlzIhNZsLiwGShiMjVXSc1wlzCrJ YOzq55AfX0zyfraOrd1EFzh67IN2CHysZDnjDlTZzw5Ul5sgvZpkLJVpQDsFcwM4 RU9Q/uf554pP/xfgXOIvUnI3O4KrJVFbe/NeMv1k= 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:to:from:subject:message-id:date:mime-version :content-type:content-transfer-encoding; s=default; bh=Hfmb5FxpF 6kykbFeSyNqjcqGJps=; b=OuGEQxUO24vuqxgJpV3iWdyUNlDKhniREmHsZeAIh YjGd+svTdto3iMaJkR9V1TiCLLHmsNKcAjfjrbtgZ6yRfIN0mTcTtY/sQpRBgxmO rh1zmPxI9LYZLkcXJauQ4mnOxQQmsw3DpWBCVPV+8hJU/eyCbjz6vjOgJh2KZluc Do= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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-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 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== To: cygwin AT cygwin DOT com From: =?UTF-8?Q?=c3=85ke_Rehnman?= Subject: Incorrect behavior in TIOCINQ ioctl Message-ID: Date: Thu, 27 Feb 2020 22:38:48 +0100 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 Note-from-DJ: This may be spam 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