gpt4 book ai didi

c - 写入返回值 c

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:31:50 28 4
gpt4 key购买 nike

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

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com