Cygwin's writev() non-standard behavior
Wed Apr 23 14:43:00 GMT 2014
On 04/23/2014 08:06 AM, qq qq wrote:
> writev() does not accept count 0 but it should
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.
> $ cat test.c
> #include <stdio.h>
> #include <errno.h>
> #include <stdlib.h>
> #include <string.h>
> #include <sys/uio.h>
> int main()
> struct iovec vec;
> memset(&vec, 0, sizeof(vec));
> if (writev(1, &vec, 0) < 0)
But in your case, fd 1 is a terminal...
> $ 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.
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 604 bytes
Desc: OpenPGP digital signature
More information about the Cygwin