public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: Cygwin's writev() non-standard behavior
@ 2014-04-23 15:48 qq qq
  2014-04-23 16:44 ` Corinna Vinschen
  2014-04-23 18:44 ` Christopher Faylor
  0 siblings, 2 replies; 9+ messages in thread
From: qq qq @ 2014-04-23 15:48 UTC (permalink / raw)
  To: cygwin

> I applied a patch to CVS.

Thanks.  Although I could not see it in ViewVC -- the page stops loading at the "configure" script.

Anyhow, I suppose that check_iovec still returns EINVAL for count==0 in any read functions:  simply returning
"tot"==0 means EOF in many (if not all) of them.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: Cygwin's writev() non-standard behavior
@ 2014-04-23 14:53 qq qq
  2014-04-23 16:24 ` Eric Blake
  0 siblings, 1 reply; 9+ messages in thread
From: qq qq @ 2014-04-23 14:53 UTC (permalink / raw)
  To: cygwin

> furthermore, cygwin should emulate Linux behavior, even if POSIX
> doesn't define the behavior.

And which is why I compared Linux vs. Cygwin in my original post ?

> so your argument is flawed - you have triggered undefined behavior.

Same difference:
$ cat test.c
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/uio.h>

int main()
{
  struct iovec vec;
  int fd = open("test.out", O_WRONLY | O_CREAT, 0666);
  memset(&vec, 0, sizeof(vec));
  if (writev(fd, &vec, 0) < 0)
    perror("writev");
  return 0;
}

Linux:
$ gcc -Wall test.c
$ ./a.out

Cygwin:
$ gcc -Wall test.c
$ ./a.exe
writev: Invalid argument

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

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Cygwin's writev() non-standard behavior
@ 2014-04-23 14:06 qq qq
  2014-04-23 14:43 ` Eric Blake
  2014-04-23 15:29 ` Corinna Vinschen
  0 siblings, 2 replies; 9+ messages in thread
From: qq qq @ 2014-04-23 14:06 UTC (permalink / raw)
  To: cygwin

writev() does not accept count 0 but it should

$ 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)
    perror("writev");
  return 0;
}

Linux:
$ gcc -Wall test.c
$ ./a.out

Cygwin:
$ gcc -Wall test.c
$ ./a.exe
writev: Invalid argument

This behavior is buggy per:

       EINVAL ... the vector count count is less than zero or greater than the permitted maximum ...

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-04-23 18:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-23 15:48 Cygwin's writev() non-standard behavior qq qq
2014-04-23 16:44 ` Corinna Vinschen
2014-04-23 18:44 ` Christopher Faylor
  -- strict thread matches above, loose matches on Subject: below --
2014-04-23 14:53 qq qq
2014-04-23 16:24 ` Eric Blake
2014-04-23 14:06 qq qq
2014-04-23 14:43 ` Eric Blake
2014-04-23 14:53   ` Eliot Moss
2014-04-23 15:29 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).