On Mon, 13 Mar 2000, J. David Bryan wrote:
> char x[100];
>
> ... = read (..., &x, 200);
>
> Surely this cannot be viewed as correct?
If the actual file only has 100 bytes, why is this incorrect?
> Or are you saying that returning "-1" is in error?
That, too. It should return what it read and set errno (IMHO).
> I gather Cygwin's "read" routine is attempting to ensure that it doesn't
> segfault due to an improperly sized buffer.
If it wants to do that, it should do it on a byte by byte basis. I don't
think such extended input verification should be done by a library,
anyway.
But this is for Cygwin maintainers to decide, let's just make sure they
are aware of the problem.
> > I'm not sure the fixed code is good enough for Unix (the file could grow as
> > you read it), but it surely is good enough for DOS/Windows.
>
> The file is opened O_RDONLY. Does that allow for concurrent writing? I
> don't know enough Unix to know.
Yes, it is allowed, in general.