delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/04/23/10:43:27

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:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type; q=dns; s=default; b=SWbvyY
aNT28NlItmgm12NDu6Ic1RlcH7jdyA4tudfyN9o8K0aVPxIomqSh3nSLcexeDOqY
xlav8EW4Vf0p9i9Jiy1xoVSQq/i/FWlMNUqSS6SnRS6M6Bo4sxZ88CIZktIfYnm6
46C8P6FALmaRAmQNSUm5HUVi5F995IEMkwByc=
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:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type; s=default; bh=ogEs04y+ZVfb
gK3mPwSFCYQSBIc=; b=e1Z1t47anDijrALeJVJlCEH2P1UEtk5bk5sE0PndssdF
Z2aaVCQ+p/Wp4/kW+n8bSCbFjlCpmNoFHWWPcjLej/+Z3lNGJjEMR3x/zSH0q3Ir
V/k69f1afR9y8lRL8IH9J1PmVxjo8LNH1kYr7o9rW116ul0YB8SWRvywP9+H59w=
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-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
Message-ID: <5357D176.4010203@redhat.com>
Date: Wed, 23 Apr 2014 08:43:02 -0600
From: Eric Blake <eblake AT redhat DOT com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Cygwin's writev() non-standard behavior
References: <20140423140635 DOT 156430 AT gmx DOT com>
In-Reply-To: <20140423140635.156430@gmx.com>
OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg
X-IsSubscribed: yes

--gqWDgoIdBHuK5tOQsV9AU9s54uCefp0Xq
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

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 <stdio.h>
> #include <errno.h>
> #include <stdlib.h>
> #include <string.h>
> #include <sys/uio.h>
>=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"

-----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--

- Raw text -


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