| Previous | Next |
| ENOTEMPTY | ENOPROTOOPT |
ENOMSG
A queue state result, not a broken queue
ENOMSG is commonly returned by msgrcv() when the caller asks for a message without waiting and no message matching the requested type is present. The queue can still exist, contain other message types, and be functioning normally. The result is therefore closer to “nothing currently matches this selection” than to an I/O failure.
The selected type matters. System V message queues allow receivers to request the first message, a specific positive type, a message of a different type, or the lowest suitable type for a negative request. A producer and consumer can both be healthy yet disagree on that selection rule. With checkpoint-oriented MSG_COPY, an unavailable ordinal position can also produce the same result.
How to use it correctly
- Record the queue identifier, requested type, flags, and queue depth when handling the result.
- Use
IPC_NOWAITonly when polling or a no-message outcome is an expected part of the protocol. - Do not treat
ENOMSGas proof that a producer is dead; check type selection and consumer competition first. - Use a timeout, event-driven wakeup, or explicit application acknowledgement when polling would create unnecessary load.
References
Looking for a different code? Search another status or error code.
