As I understand, 'MAP_SHARED' flag in mmap() shares any changes made by a process to the memory map immediately with other processes and eventually writes the changes back to the file. Is it possible to share the in-memory changes with other processes but not write the changes back to file? Does it need a new type of flag? How complex would be to implement that kind of flag (e.g. 'MAP_SHARED_NOT_WRITE_BACK)?
=======================================
Added: The usecase I have in mind: Process A mmap's the code segment of a shared library foo.so and makes changes to the code (for example, encrypt the code). I want other processes B, C, etc. created later on and using foo.so share the modified code. I, however, don't want the changes written back to foo.so file. I would prefer a scalable solution that works for multiple processes and many shared libraries.
shm_open()
?) and just seed it with the file data? – ilkkachu Aug 19 '21 at 20:07