在 linux 机器上,
写入文件的 write() 或 writev() 写入的字节数少于给定的字节数的原因是什么?
我知道它是一个有效的返回值,可以返回 > 0 和 < 您给 write 调用的大小,但我很好奇为什么会发生这种情况......
最佳答案
the documentation 中列出了几个原因,包括:
If a
write()
requests that more bytes be written than there is room for (for example, the process' file size limit or the physical end of a medium), only as many bytes as there is room for shall be written.If
write()
is interrupted by a signal after it successfully writes some data, it shall return the number of bytes written.
关于c - 写入返回值 c,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4742847/