Mail Archives: cygwin-developers/2000/04/03/13:36:13
On Mon, Apr 03, 2000 at 03:37:57PM +0200, Corinna Vinschen wrote:
>=== SNIP ===
>#include <sys/types.h> etcetera...
>...
>int
>main(int argc, char** argv)
>{
> int fd;
> char buf1[64000];
> ssize_t bytes;
>
> if ((fd = open (argv[1] ? argv[1] : argv[0], O_RDONLY)) < 0)
> return 0;
> lseek (fd, (off_t) 0, SEEK_END);
> bytes = read (fd, buf1 + 64000, 40000);
> printf ("read: %d, err: %d, %s\n", bytes, errno, strerror(errno));
> close (fd);
> return 0;
>}
>=== SNAP ===
>
>and the message is
>
>read: -1, err: 14, Bad address <=== EFAULT!
>
>as it's currently under cygwin, too, and it _is_ an UNIX-style error.
>This is documented in the linux read(2) man page as well.
>
>So, if this behaviour is the same in a "reference os", where is
>the problem??? Well, uhm, I have no copy of POSIX, obviously...
That's not quite the same thing. The behavior as I understand it is
something like this:
#include <sys/types.h> etcetera...
...
int
main(int argc, char** argv)
{
int fd;
char buf1[64000];
ssize_t bytes;
if ((fd = open (argv[1] ? argv[1] : argv[0], O_RDONLY)) < 0)
return 0;
lseek (fd, (off_t) -2, SEEK_END);
bytes = read (fd, buf1 + (64000 - 2), 40000);
printf ("read: %d, err: %d, %s\n", bytes, errno, strerror(errno));
close (fd);
return 0;
}
This supposedly works on UNIX and fails on Cygwin.
cgf
- Raw text -