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

如果你使用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 – 杀死你的应用程序.

相关文章

文章浏览阅读1.8k次,点赞63次,收藏54次。Linux下的目录权限...
文章浏览阅读1.6k次,点赞44次,收藏38次。关于Qt的安装、Wi...
本文介绍了使用shell脚本编写一个 Hello
文章浏览阅读1.5k次,点赞37次,收藏43次。【Linux】初识Lin...
文章浏览阅读3k次,点赞34次,收藏156次。Linux超详细笔记,...
文章浏览阅读6.8k次,点赞109次,收藏114次。【Linux】 Open...