Is there a way for process A (which created a shared memory segment using the POSIX shm_open
library - I'm not interested in the SysV shared memory API) to detect that process B has opened the same shared memory segment? I need a way for process A to start "work" after process B has opened the same shared memory. The proposal is for A to poll something until B is connected. (In my case, there are actually 3 processes B1,B2,B3 so I need to wait until all 3 have opened the shared memory).
I've been toying with using lsof /dev/shm/foo
and scrape the process IDs, but I'd like to not have to invoke a shell just to do this.
I see other SO answers that solve this problem by creating a semaphore and I could also use some other messaging system, but I was looking for a solution with less moving parts.