When memory mapping files in a POSIX
system, do we need to keep the file-descriptor open till we're done with the mmap
ed 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.
精彩评论