加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 程序存在异常时,是否刷新fwrite()缓冲区中的数据?

发布时间:2020-12-16 03:48:01 所属栏目:百科 来源:网络整理
导读:fwrite()是一个库调用,它首先将数据缓冲到用户空间缓冲区中,然后稍后调用write()系统调用来实际执行写操作. If a program invokes fwrite() to write some data to a file but then exists abnormally,will the buffer of fwrite() be cleared flushed,or th
fwrite()是一个库调用,它首先将数据缓冲到用户空间缓冲区中,然后稍后调用write()系统调用来实际执行写操作.

If a program invokes fwrite() to write some data to a file but then exists abnormally,will the buffer of fwrite() be cleared flushed,or the buffered data will be left over in memory?

我正在考虑的操作系统是Linux.

解决方法

如果程序异常退出,则不会刷新任何缓冲的数据.操作系统只是说“哦,亲爱的,你把文件描述符打开了,我最好为你关闭”,当进程终止时;它不知道有一些随机数据存在于内存中,程序打算写入磁盘但没有.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读