在Linux上是否关闭()调用的fsync()?

编程入门 行业动态 更新时间:2024-10-13 02:16:18
本文介绍了在Linux上是否关闭()调用的fsync()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我们调用接近(小于FD>),它自动执行 FSYNC()同步到物理介质?

When we call close(<fd>), does it automatically do fsync() to sync to the physical media?

推荐答案

它没有。调用的close()并不能保证内容是在磁盘上的操作系统可能会推迟写入。

It does not. Calling close() DOES NOT guarantee that contents are on the disk as the OS may have deferred the writes.

作为一个方面说明,经常检查的返回值的close()。它会让你知道任何递延错误到这一点的。如果你想以确保内​​容是在磁盘上始终调用 FSYNC()并检查其返回值也是如此。

As a side note, always check the return value of close(). It will let you know of any deferred errors up to that point. And if you want to ensure that the contents are on the disk always call fsync() and check its return value as well.

有一点要记住的是后备存储是什么。有迹象表明可能会做内部写管理延迟和内容在某些情况下会丢失(尽管新的存储介质的设备通常具有超级电容器以prevent这一点,或者方法来禁用此功能)的设备。

One thing to keep in mind is what the backing store is. There are devices that may do internal write deferring and content can be lost in some cases (although newer storage media devices typically have super capacitors to prevent this, or ways to disable this feature).

更多推荐

在Linux上是否关闭()调用的fsync()?

本文发布于:2023-10-09 05:41:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1474857.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Linux   fsync

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!