I have a resource which I need to protect access to within a process, and across multiple processes. I\'ve managed this by creating a named mutex via boost::interprocess:n
There isn't any reference counting supported to my knowledge.
If you are starting or stopping your processes using for example shell script you could remove the shared memory files at start/stop from the script.
If you have one process that is always starting first then you could use it to remove shared memory files at program start (or similarly in last stopping process at program stop).
Another approach would be implementing reference counting yourself using shared memory - last process would delete all shared memory files. However this won't work if one of the processes crash, you could still try removing in segfault signal handler but this may not always work too.
Update: As @sehe mentioned boost::interprocess::shared_ptr
can be used for reference counting.