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

前端之家收集整理的这篇文章主要介绍了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 – 杀死你的应用程序.

猜你在找的Linux相关文章