Is a return value of 0 from write(2) in C an error?

前端 未结 4 1338
慢半拍i
慢半拍i 2020-12-15 08:07

In the man page for the system call write(2) -

ssize_t write(int fd, const void *buf, size_t count);

it says the following:

4条回答
  •  暖寄归人
    2020-12-15 08:34

    Stevens probably does this to catch old implementations of write() that behaved differently. For instance, the Single Unix Spec says (http://www.opengroup.org/onlinepubs/000095399/functions/write.html)

    Where this volume of IEEE Std 1003.1-2001 requires -1 to be returned and errno set to [EAGAIN], most historical implementations return zero

提交回复
热议问题