I have an mqueue which has 2 messages in it but the call to mq_receive will not pull data. I don't have any previous experience with this message queue so forgive my ignorance. I believe the send side is working fine as echoing the "file" does show information.
QSIZE:48 NOTIFY:1 SIGNO:0 NOTIFY_PID:5741
This is 2 messages without a message signal being generated. The PID is the process that will be calling mq_receive.
For reference, here is the open code.
msgq_attr.mq_maxmsg = MAX_NUM_MESSAGES; // 20
msgq_attr.mq_msgsize = MAX_MSG_SIZE; // 256
mqrcv_id = mq_open(queue_name, O_RDONLY | O_NONBLOCK,
S_IRWXU | S_IRWXO, msgq_attr);
notify.sigev_notify = SIGEV_NONE;
notify.sigev_notify_attributes = NULL;
mq_notify(mqrcv_id, ¬ify);
And here is the receive.
int msgSize = mq_receive(mqrcv_id, buffer,
MAX_MSG_SIZE, &msgprio);
msgSize always returns -1 with errno EAGAIN. From the documentation, this should mean that the queue has no messages in it. Note that it is NONBLOCKING.