Well, the only way I can come up with a portable POSIX API is to have the child map a new segment of the same size somewhere else (random), copy the data and then separate the original segment and reattach the new segment to the correct address. That sounds ugly.
You can disconnect a new segment after you do this so that other people do not join it.
Now, when I look at the man page, if you have an FD for the shm object, you can try rewinding the shm object as MAP_PRIVATE to a child at the right address. However, `` It is not indicated whether changes made to the file after calling mmap () will be visible in the displayed area. '', Therefore, you either need to check this, or it is dangerous to live, or use other equipment.
source
share