问题描述
在调用之前 fflush
我可以考虑 FWRITE
是=非阻塞写?
如果不是,为什么不和我有哪些办法?
Before calling fflush
can I consider fwrite
to be = a non-blocking write?If not, why not and what are my alternatives?
推荐答案
技术上的fwrite()是一个阻塞调用,它不返回,直到程序已完成。但是对于完成fwrite()将定义为您提供的数据已被写入到一个内部文件缓冲区。作为一个副作用,一些缓冲,也可能被写入到磁盘和fwrite()调用的一部分,但你不能依赖这种行为。如果你绝对需要的数据在磁盘上,你需要调用fflush()。
Technically fwrite() is a blocking call in that it does not return until the procedure has completed. However the definition of completion for fwrite() is that the data you supply has been written to an internal file buffer. As a side effect some of that buffer may also be written to the disk as part of the fwrite() call but you cannot rely on that behavior. If you absolutely require the data to be on the disk you need to call fflush().
这篇关于是FWRITE非阻塞?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!