> I'm about to take my first stab at using mmap() and friends in a project
> I'm working on. One thing I'm wondering about, though: what happens if
> some other process tries to write to a file that is currently mmapped?
Then the file is modified.
Quote:> Will the image in memory be automatically updated?
There is no image in memory. The file itself is mapped into memory.
Quote:> Will the external
> writes go unnoticed by the process using mmap?
I'm not sure I understand what you mean. The file will be modified. The
file itself (its contents) are mapped into the process' memory. The
'mmap' function actually maps a file's contents into the memory space of
a process (assuming a share mapping).
Quote:> What happens if I try to
> do a subsequent msync() after the external process has written something?
Read closely the man page for 'msync'. It has nothing to do with the
mapping itself. It flushes changes made to the cached copy of the file
to disk.
Quote:> How does one avoid any possible calamities?
The same way you do for the write and read functions. The 'mmap' system
call just makes file access easier, it doesn't really change the
semantics.
DS