The correct way to list the queues on the Linux machine is by using the ipcs -q
command. However, I have not seen anything in the system calls that would provide such a capability. But Today I Learned…
The ipcs utility has two ways of retrieving the list of queues. The first and main one is to read and parse /proc/sysvipc/msg
. If the file is not present, it does a fallback by using a strange Linux-specific msgctl
call with MSG_INFO
command. Which among other things has this property:
And then it’s just a loop from 0 to that max ID and checking all possible queue identifiers.
Top comments (0)