I have two processes given by their pids: P1 and P2. Is there are a simple way of chcecking whether these processes are communicating via sockets or other inter-process communication mechanism? I need to know this because I have two seemingly unrelated apps that might be communicating under the hood and I want to know if this is really the case.

  • Have you tried to use ss to see list of sockets opened by process? You also may use strace to check exactly what does process do – user996142 Jul 5 '17 at 18:01

You can use lsof -p P1 and lsof -p P2 to see the file descriptors open by the two processes. Then you can look at the list of sockets and pipes they each have open, and see if any of them have the same ID.

imac:barmar $ sleep 100 | sleep 100 &
[1] 51885
imac:barmar $ jobs -l
[1]+ 51884 Running                 sleep 100
     51885                       | sleep 100 &
imac:barmar $ lsof -p 51884 | grep -i pipe
sleep   51884 barmar    1   PIPE 0x491a6929f9ea1ca9     16384          ->0x491a6929f9e9fae9
imac:barmar $ lsof -p 51885 | grep -i pipe
sleep   51885 barmar    0   PIPE 0x491a6929f9e9fae9     16384          ->0x491a6929f9ea1ca9

Notice that the destination ID of the pipe in the first process is the same as the source ID of the pipe in the second process. That indicates that they're the two ends of the same pipe.

| improve this answer | |

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.