Question

I open shared memory and semaphores with the appropriate flags:

sem = sem_open("/some_name", O_CREAT | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO, 1);
shm = shm_open("/other_name", O_RDWR | O_CREAT | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);

The calls don't fail (I check them) and indeed one process who fork/execs other processes creates them and the other processes do share the memory and semaphores and there is proper synchronization.

When I use the ipcs command however, I don't see the shared memory nor the semaphore. Why is that? If they don't appear with ipcs, where can I check them?


In my ipcs output I don't have any entries in the Semaphore Array list and the ones in shared memory are related to skype, firefox and plugin-container (of firefox). I checked them with

grep shmid /proc/*/maps     # observe pid
readlink /proc/pid/exe
Was it helpful?

Solution

One solution I just found was that shared memory and shared semaphores are listed under:

/dev/shm

The files there are useful for knowing what shared objects there are and maybe to unlink them, but they don't provide any useful information beyond that (as ipcs does).

OTHER TIPS

Ipcs reports only System V shared memory. You must be using Posix shared memory. Apparently these are two completely different mechanisms. Posix shm is shown under /dev/shm.

I've had the same issue, and the accepted answer is not satisfying enough as it is not explaining why this is happening. I found the answer in another similar question: i cannot see the shared memory created by the boost::interprocess via shell command ipcs

"As far as I'm aware, ipcs reports only System V shared memory. POSIX shared memory is a separate area, and has to be queried separately. On linux systems, check /dev/shm."

In my case the solution was to use sudo:

sudo ipcs -m
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top