Hi Raul, Raul Miller wrote on Wed, Sep 20, 2017 at 06:31:03PM -0400:
> What are the correct cases where write(2) writes 0 bytes and that is > considered success (as opposed to being one of the documented error > cases)? Most importantly, nbytes == 0. On OpenBSD, we are not aware of any other such cases. Elsewhere, i already cited this from the POSIX RATIONALE: Also, some existing systems (for example, Eighth Edition) permit a write of zero bytes to mean that the reader should get an end-of-file indication; for those systems, a return value of zero from write() indicates a successful write of an end-of-file indication. That behaviour seems very obsolete to me, though, and in violence of the POSIX requirements. Theoretically, there might be systems out there containing special devices that may do successful partial writes of 0 bytes even when given nbytes > 0, and which might write more on a later retry. I'm not aware of any specific examples, though. If they exist, they would be hard to use correctly because you would have to avoid dangers both of expensive busy loops and of endless loops when getting 0 and then repeating write attempts to them. Note that the code example i added suggests to treat 0 as *failure* for nbytes > 0, not as success. Yours, Ingo
