I am trying to understand what happens when a file, which has been mapped into memory by the
mmap system call, is subsequently written to by other processes.
mmaped memory with
PROT_READ protection in "process A". If I close the underlying file descriptor in process A, and another process later writes to that file (not using
mmap; just a simple redirection of stdout to the file using
> in the shell), is the
mmaped memory in the address space of process A affected? Given that the pages are read-only, I would expect them not to change. However, process A is being terminated by
SIGBUS signals as a result of invalid memory accesses (
Non-existent physical address at address 0x[...]) when trying to parse the mapped memory. I am suspecting that this is stemming from writes to the backing file by other processes. Would setting
MAP_PRIVATE be sufficient to completely protect this memory from other processes?