Home > Net >  What happens if two distinct processes use mmap to map the same region of file (one with MAP_SHARED,
What happens if two distinct processes use mmap to map the same region of file (one with MAP_SHARED,

Time:05-27

Can two distinct(not parent/child) processes use mmap to map the same region of file, the process A with flag MAP_SHARED, the process B with MAP_PRIVATE)? If process A changes something in the region, can the process B see it?

CodePudding user response:

Then A gets the file mapped and B gets the file mapped but any writes will not be written back to the file.

From the manpage:

It is unspecified whether changes made to the file after the mmap() call are visible in the mapped region.

  • Related