delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/02/28/14:24:29

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:date:from:to:cc:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=yKY64WZk/EPWQqkqCeP+iRz8vu/9FFR6KaYOqQDtVWOFbscF6Mv6k
KMxJYZBOGOa8WTxtZh1OpIMxjNwo57uktG+AsZiIIJ0QLKkbZxKMuqHe6oluJRrH
RApp63QHE7kzxaurtuxaucGpsGahV7nFUrLcRTk9Gd29e+nmfG+pHs=
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:date:from:to:cc:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=Lf20VRMuhr/14ibBOCsCXEXlwqs=; b=FgnnTudWb+Gj9Gq8mj+Qf36PteFU
uojFXRyjsY1PTu3+jp1DSw5shyWAMNVfIW1PwRof6cHC9e6jOxlmEZatPhpBoEx4
eU52QGBXh4ZtfHO+wvQblRcMqPMygT5h8Pw2myJGMZ6/wwGkLaBDbbwneqED/rWA
ESwydy8N2nsbpPQ=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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=-106.4 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1656
X-HELO: mout.kundenserver.de
Date: Fri, 28 Feb 2020 20:23:30 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Cc: =?utf-8?Q?=C3=85ke?= Rehnman <ake DOT rehnman AT gmail DOT com>
Subject: Re: Incorrect behavior in TIOCINQ ioctl
Message-ID: <20200228192330.GN4045@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com, =?utf-8?Q?=C3=85ke?= Rehnman <ake DOT rehnman AT gmail DOT com>
References: <d6a35f8b-3e4d-c8c6-4d3c-f15ccd72866d AT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <d6a35f8b-3e4d-c8c6-4d3c-f15ccd72866d@gmail.com>

--yhqQ34TVR4fE8mPU
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Feb 27 22:38, =C3=85ke Rehnman wrote:
> Hi,
>=20
> 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 existi=
ng
> framing overrun errors etc etc=C2=A0 before calling the TIOCINQ ioctl it =
is
> returning an error (EINVAL). Reading through linux implmentation of TIOCI=
NQ
> does simply return number of pending chars without any clearing or checki=
ng
> for errors.
>=20
> I suggest the whole if (ev & CE_FRAME=C2=A0 ...... ) is removed.
>=20
> Excerpt from fhandler_serial.cc:
>=20
> /* ioctl: */
> int
> fhandler_serial::ioctl (unsigned int cmd, void *buf)
> {
> .
> .
> =C2=A0 if (!ClearCommError (get_handle (), &ev, &st))
> =C2=A0=C2=A0=C2=A0 {
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __seterrno ();
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 res =3D -1;
> =C2=A0=C2=A0=C2=A0 }
> .
> .
> .
> =C2=A0=C2=A0=C2=A0=C2=A0 case TIOCINQ:
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ev & CE_FRAME || ev & CE_IOE || =
ev & CE_OVERRUN || ev & CE_RXOVER
> =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 || ev & CE_RXPARITY)
> =C2=A0=C2=A0=C2=A0 =C2=A0{
> =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 set_errno (EINVAL);=C2=A0=C2=A0=C2=A0 /* =
FIXME: Use correct errno */
> =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 res =3D -1;
> =C2=A0=C2=A0=C2=A0 =C2=A0}
> =C2=A0=C2=A0=C2=A0=C2=A0 else
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 ipbuf =3D st.cbInQue;
> =C2=A0=C2=A0=C2=A0=C2=A0 break;

I'm not familiar with serial I/O and the code is pretty stable(*).

- Is it a safe bet that ClearCommError returns valid values in
  st.cbInQue even if one of the error conditions occur?  Maybe the
  right thing to do is to return 0 in certain error cases...?

- Did you actually try if this fixes your problem?  It's pretty
  simple to build the Cygwin DLL
  https://cygwin.com/faq.html#faq.programming.building-cygwin


Corinna

(*) euphemistically for "nobody looked into the code for a long time"


--=20
Corinna Vinschen
Cygwin Maintainer

--yhqQ34TVR4fE8mPU
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl5ZaLIACgkQ9TYGna5E
T6DDRA/9HwYFl/XnWKztbNxO4UN9vn3nvvETQSuzQ9E8ALcViMiZPB0xgW4XcLXW
t34xCVwie/7zR15qV5lM51fof77Yp4zg0v3Qal5EnlIp8Eb+v63vmTOpafYhy4kE
m+juaw6KMpcQ+YCCiT3mBh/2p9NWpadxY4Y5SYpiBwE0j/JsRJd5bgfyEaGPcQsW
ZQq//gtcg4Zfud/hC/hz55nD7W9bKtNjZhobvP0e+odhTxEvCI3sxFQ6KOPQvVyQ
uQHfgOZnDWlDRaQWcKnBFWqJLZLu7t1Ajvdr0R7emBwepZOyqVkRA0eJzN05x5hR
37brWwc2oFrG0fr8cKIGPqymYxVYFB0RnSO53pRNMJ76HgP5jzPzDQKS3l/cpn0J
Lg2cLB6VOgPSFX+VUMS1fCHQwDhvDY0bxL7IE0lCSA+FzP2TUbpoGuSkhtwXkuXc
XdDlEEqOWlDXfIBLu053ZXh+dArtjSO/PoyGd4NJn3gS5diPXsT88UqfnKRZ/PhH
04ys0aHuN/wVPS9TPdrGwOziH96ACUryx/zX2fCZ5tIZrUBoyymeFg+dxfvThhwz
kPNg/HFio0OoiV63kinJRd3Ev4Yw2D5sOV4njexpdM/2kKra28KUz934YAEdPDvb
Frcswxbh80ctvO9m6nwpEJmClFPcBPusdA3OTkXN2j5fSHbSa2E=
=KgDs
-----END PGP SIGNATURE-----

--yhqQ34TVR4fE8mPU--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019