Search code examples
clinuxshared-memoryipcs

ipcs doesn't show my shared memory and semaphores


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

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