I have an application which uses message queues. I sometimes get an error message when trying to post a message on the queue.
The error is EINVAL. According to the documentation on this system call,
the meaning is as follows.

One of the following cases is true:
msg_len was negative
msg_prio was greater than MQ_PRIO_MAX
msg_prio was less than 0
the MQ_PRIO_RESTRICT flag was set in the mq_attr member of mqdes, and msg_prio was greater than the priority of the calling process

All of this does not make any senses for my application since the msg priority is always 0, the message length uses a #define constant because the message length is always the same size and the MQ_PRIO_RESTRICT flag is not being set.

Has anyone come across this same issue?


I have not come across this, but I have some suggestions.

  1. try inserting the #define constant directly, maybe play with the size a bit
  2. try to create a simple isolated version of the problem that fails
    Usually doing 2 will shake out the problem, but if it doesn’t you can post
    the code and others can take a look.