c - 写入返回值 c

标签 c linux posix

在 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/

相关文章:

c - 向二进制添加奇偶校验,即汉明码

c - 我想扫描 txt 文件并将这些数字保存在数组中

c - 用于打印 “stat”缓冲区内容的格式说明符

c++ - 如果 pthread_cond_signal 是线程中的最后一次调用,是否存在数据竞争?

r - 使用正则表达式和 POSIX 字符类验证 R 中的密码

c - gets() 和 scanf() 有什么区别

c - execl 和 execv 有什么区别?

linux - 我不小心复制了一个 bash 文件,并将其替换为 Linux Mint 中的 .bashrc 文件。我该如何检索 .bashrc 文件?

linux - 简单的内存共享问题

c - 找出 100 到 40 之间 3 的倍数的数字