This is related to my previous question.

Given that I can find the statistics of IPC channels in my Linux system (e.g. sys V IPC), how can I find which processes are using certain IPC channel (sending via channel; receivers are usually mentioned in command outputs).

For example, ipcs gives me a list of shared mem id's on the machine. How can I find which processes are using that shared memory ?

The other IPC's I am interested in (these are the commands I used to find the statistics):

  • Pipes: lsof | grep pipe
  • UNIX Domain sockets: netstat -n

You also use ipcs, but add extra options:

wouter@gangtai:~$ ipcs

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages    

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x0052e2c1 32768      postgres   600        56         20                      
0x00000000 17924097   wouter     600        33554432   2          dest         
0x00000000 49446914   wouter     600        524288     2          dest         
wouter@gangtai:~$ ipcs -i 17924097 -m -p

Shared memory Segment shmid=17924097
uid=1000    gid=1000    cuid=1000   cgid=1000
mode=01600  access_perms=0600
bytes=33554432  lpid=3808   cpid=1457   nattch=2
att_time=Fri Jul  3 10:43:28 2015  
det_time=Fri Jul  3 10:43:28 2015  
change_time=Fri Jul  3 10:03:00 2015  

lpid is the "last accessor" PID; cpid is the "creator" PID.

The -i parameter needs the id of the IPC object (shared memory segment, message queue, or semaphore) that you want to inspect. The -m flag is because we're inspecting a memory segment, and the -p says we want to see process IDs.

See man ipcs for the full story.

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.