I want to create a number of named memory regions in my program, and mmap
them somewhere so that other processes can read them. I can't guarantee that only one instance of my program will run at a time. Ideally, I'd like to put the blocks under /proc/self/<blockname>
or such. Is this possible? Or is there another place I can put the mapped files? (My program will normally not run as root.)
I don't want to use /proc/self/fd
or /proc/self/map_files
, since that doesn't allow naming them (as far as I know).
Best Answer
No, you cannot add your structure in a meaningful way to
/proc
because it is generated (not a "real" filesystem). Likewise/sys
on some machines. Changing the structure of/proc
isn't straightforward (see for example Creating a folder under /proc and creating a entry under the folder).Further reading:
@mark-plotnick suggested POSIX shared memory, which does support names.
Further reading:
(These are named objects)