Possible Duplicate:
Is a return value of 0 from write(2) in C an error?
Assuming that count > 0 :
ret = write(fd, buf, count);
if(ret == 0) {
// Should I try to write again
// or treat this as error?
}
Are there any circumstances in which this condition is possible?
Unless you explicitly passed a length of zero to
write, this will never happen on a correct, POSIX conformant system. If you want to support all kinds of obscure broken legacy proprietary unices, you’ll probably have to investigate what happens on each one, and whether the return value of zero is appearing in place ofEINTRor in place ofEWOULDBLOCKor some other error…Personally in 2011 I would just assume it doesn’t happen. There are a lot of other things which will break much worse trying to support such old broken junk..
Note, per POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html