From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3267 invoked by alias); 23 Apr 2014 14:43:06 -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 3228 invoked by uid 89); 23 Apr 2014 14:43:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Apr 2014 14:43:04 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3NEh3QJ028297 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Apr 2014 10:43:03 -0400 Received: from [10.3.113.108] (ovpn-113-108.phx2.redhat.com [10.3.113.108]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3NEh2Fp007405 for ; Wed, 23 Apr 2014 10:43:02 -0400 Message-ID: <5357D176.4010203@redhat.com> Date: Wed, 23 Apr 2014 14:43:00 -0000 From: Eric Blake User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: cygwin@cygwin.com Subject: Re: Cygwin's writev() non-standard behavior References: <20140423140635.156430@gmx.com> In-Reply-To: <20140423140635.156430@gmx.com> OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gqWDgoIdBHuK5tOQsV9AU9s54uCefp0Xq" X-IsSubscribed: yes X-SW-Source: 2014-04/txt/msg00511.txt.bz2 --gqWDgoIdBHuK5tOQsV9AU9s54uCefp0Xq Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-length: 1082 On 04/23/2014 08:06 AM, qq qq wrote: > writev() does not accept count 0 but it should POSIX says: http://pubs.opengroup.org/onlinepubs/9699919799/functions/writev.html If fildes refers to a regular file and all of the iov_len members in the array pointed to by iov are 0, writev() shall return 0 and have no other effect. For other file types, the behavior is unspecified. >=20 > $ cat test.c > #include > #include > #include > #include > #include >=20 > int main() > { > struct iovec vec; >=20 > memset(&vec, 0, sizeof(vec)); > if (writev(1, &vec, 0) < 0) But in your case, fd 1 is a terminal... > Cygwin: > $ gcc -Wall test.c > $ ./a.exe > writev: Invalid argument so your argument is flawed - you have triggered undefined behavior. That said, if you can reproduce it with ./a.exe > file, you have proven a bug; furthermore, cygwin should emulate Linux behavior, even if POSIX doesn't define the behavior. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --gqWDgoIdBHuK5tOQsV9AU9s54uCefp0Xq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 604 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTV9F2AAoJEKeha0olJ0NqQc8H/iZyACXzk5XeaPd3268MUEUO zRHUbqQGSyEwxZJVYwcGKKuHPRF8fCbLQ5ALosVcA893w1ar50r2Tbycz0c/Mpik e7G6jF1sVw5J88k5UnKmSvZ6KYWHHGXGc2t2mmiWkqisyOQ/ZTGwHDy6ybmbAuc0 19m0dFQtuImotRTr06Wa/koNJk4WTqf/GnGtAaYiro7PUKlHpoxXujHmE7vVg3J2 319T66u4LnF7btLIvRF+aXOKN/GkfTEK/dpHU5RjeyyHoyxKo0K198oDElsmkR21 YNPiDWD1Al+g0e0gZxOB9lUFpXxEUT+IiUuL2+4CdPxaZWtcol+0gw0c0qlIZ68= =pb94 -----END PGP SIGNATURE----- --gqWDgoIdBHuK5tOQsV9AU9s54uCefp0Xq--