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

c – mmap():如果底层文件发生变化(收缩)会发生什么?

发布时间:2020-12-13 18:54:58 所属栏目:Linux 来源:网络整理
导读:如果你使用mmap()对内存映射文件,但是底层文件会变得更小.如果您访问从文件中删除的内存偏移量会发生什么? 最佳答案 IBM表示它未定义http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Fapis%2Fmmap.htm If the size of the mapped

如果你使用mmap()对内存映射文件,但是底层文件会变得更小.如果您访问从文件中删除的内存偏移量会发生什么?

最佳答案
IBM表示它未定义http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Fapis%2Fmmap.htm

If the size of the mapped file is decreased after mmap(),attempts to reference beyond the end of the file are undefined and may result in an MCH0601 exception.

If the size of the file increases after the mmap() function completes,then the whole pages beyond the original end of file will not be accessible via the mapping.

在SingleUnixSpecification中也是如此:http://pubs.opengroup.org/onlinepubs/7908799/xsh/mmap.html

If the size of the mapped file changes after the call to mmap() as a result of some other operation on the mapped file,the effect of references to portions of the mapped region that correspond to added or removed portions of the file is unspecified.

‘undefined’或’unspecified’表示 – 允许操作系统开始格式化磁盘或任何东西.最可能的是SIGSEGV – 杀死你的应用程序.

(编辑:李大同)

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

    推荐文章
      热点阅读