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).


2 Answers 2


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:


No. The kernel decides what is in /proc/PID, not the process. (/proc/PID is what you're asking about, not /proc/self: other processes don't see your process in /proc/self.)

When processes need to convey data about themselves, the conventional place to put this information is under /var/run for processes started by the administrator (i.e. system services), and under /tmp or under the user's home directory for processes started by a user. For information tied to a process, the home directory is usually a bad idea because it can be shared between machines. Modern Linux systems also have /run/user/UID. Pick one and define a convention, e.g. a directory /tmp/myapplication-1234 or /run/user/myapplication/1234 where 1234 is the PID. Delete this directory when your process exits.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.