Reputation: 35
I am working with POSIX running on a RHEL machine. Is there a way to check the number of messages that are remaining in a message queue (System V Preferably)?
The purpose of this is simply a desire to know which queues have the most messages at a given time so that I can make a "managing" thread receive the messages in a Longest-Queue-First manner.
I didn't see anything about this in the man pages (that were C/C++-specific and not tied to IPCs).
Does anyone have an idea of how to do this?
Upvotes: 0
Views: 784
Reputation: 595557
You said in comments that you are using msgget()
to create the message queue. In that case, you can use msgctl()
to get the number of messages in the queue, via the returned msqid_ds::msg_qnum
struct field.
Upvotes: 1