开发者

Memory Mapping a file in POSIX

开发者 https://www.devze.com 2023-01-24 18:06 出处:网络
When memory mapping files in a POSIX system, do we need to keep the file-descriptor open till we\'re done with the mmaped memory block (and close it after we munmap) or can (should?) we close the file

When memory mapping files in a POSIX system, do we need to keep the file-descriptor open till we're done with the mmaped memory block (and close it after we munmap) or can (should?) we close the file descriptor once mmap succeeds? Both seem to w开发者_如何学JAVAork on my Linux system.


From the Open Group standard

The mmap() function shall add an extra reference to the file associated with the file descriptor fildes which is not removed by a subsequent close() on that file descriptor. This reference shall be removed when there are no more mappings to the file.

0

精彩评论

暂无评论...
验证码 换一张
取 消