http://www.perlmonks.org?node_id=1223437


in reply to Re: Using IPC::SharedMem to get nattch for a specific address?
in thread Using IPC::SharedMem to get nattch for a specific address?

Yup. And you really do use the key for this module. The issue was the hex value. You need to either use the signed int found in /proc/sysvipc/shm, or convert the hex value you get from ipcs. I did work out the conversion from one to the other and back again, and they definitely check out as matching each other. I find it easier to just rely upon proc, although it's arguably less portable to do so.

The shmid is actually something you get from the stat method in the module, after you've already used the key to connect to the segment.

I'm all set, and it works like a champ. My only real complaint is that there's no (apparent) method akin to select() or inotify or the like, for when nattch changes. To do what I'm doing, I absolutely must do an expensive polling loop, unfortunately. I suspect this is not a common use case, which probably explains the absence of any such creature.