Question about memory-mapped files

From: John M Collins (jmc@xisl.com)
Date: Wed May 28 2003 - 11:36:10 EST


Please cc me (jmc@xxxxxxxxxxxxxxxxxxx) in any reply as I'm not subscribed.

Could someone advise me on the answer to the following question:

If I invoke mmap to map a file to memory, and it succeeds, can I safely close the original file descriptor and rely on the memory still being mapped and the file still updated (possibly with mysnc)?

I've looked through the kernel (2.4) source and it seems I can. I've tried a test program on my machine and also Solaris and HP and it works OK the file getting updated.

On the Linux machine /proc/<pid>/maps seems to have all the right stuff in after the file is closed.

The only thing that doesn't happen is that the file mod time doesn't get changed (on any machine).

Of course "munmap" and "mremap" don't oblige you to pass an fd so it would seem logical. But no manual page actually seems to say it.

Could anyone advise? Thanks.

--
John Collins Xi Software Ltd www.xisl.com


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/