Does protection flag affect the sharing between processes? If I have PROT_READ|PROT_WRITE -protected mmapped memory region, is it still fully shared as long as I haven't written into it?
int prot = PROT_READ|PROT_EXEC;
image = mmap(NULL, filesize, prot, MAP_PRIVATE, fildes, 0);
vs:
int prot = PROT_READ|PROT_WRITE|PROT_EXEC;
image = mmap(...)
I'd want to make small modification to small portion of the memory region after I've mapped it, then re-mprotect it all, because it's simpler than mprotecting small portions when I need to do so.
The question is whether it ends up forcing the whole file copied per process or just the portions I modified per process?