开发者

Short writes to a UNIX file descriptor

When can a short write to a file descriptor occur in FreeBSD 7.2?

I mean the situation when "write" system call returns less bytes written than requested.

I'm speaking about descriptors to ordinary files in ufs filesystem which we can g开发者_StackOverflow社区et with a call to open().


write() can return fewer bytes written than requested:

There is a process context switch or a SIGINT is received, write() is not atomic. write() returns fewer bytes when EOF occurs before the whole buffer is read.

If the fd is set to non-blocking, then other transient conditions may cause write() to return having written fewer bytes than requested - this is implementation defined behavior. An example is transient disk full errors, on filesystems like /tmp. NFS filesystems do not play well sometimes: an error return from close() may be the only way you detect a disk full error on a write() to an NFS mounted file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜