Mail Archives: djgpp-workers/2003/01/24/04:04:38
Richard said:
> But if write() fails, then the file pointer is not advanced. Consider writev()
> for a vector of 2 entries, if we write() iovec-by-iovec:
>
> Entry 1: write() succeeds
> Entry 2: write() fails
>
> If we want to fail writev(), because the second write fails, then we should
> seek to the position before writev() was called.
Why do we want to fail the writev() call? It clearly succeeded in
writing the bytes it wrote from Entry 1.
I just don't get it.
Consider these cases which with your reasoning would be failures:
A. write(fd, buf, 100) returns 50. It partially wrote it. Success.
B. Your example above. It partially wrote it. Success.
C. writev(): Entry 1: write(fd, buf, 100) returns 50. It partially
wrote it.
Entry 2: don't bother. We could only write 50 of 100
before.
In total success (we wrote something), return 50.
D. writev(): Entry 1: write(fd, buf, 100) succeeds returning 100.
Entry 2: write(fd, buf, 100) returns 50. It partially
wrote it.
In total success (we wrote something), return 100+50.
Tha failure case:
If (and only if) the first write() call in writev() fails, writev()
fails.
> OK, now I'm slightly embarrassed. This is also the first time I've looked at
> the Cygwin source and they seem to use the memory allocation method too.
Why? As the licenses differ (I think), I'd be very wary of looking
there.
Right,
MartinS
- Raw text -