ENOMSG
Linux / POSIXERRORCriticalIPCHIGH confidence

No Message of Desired Type

Production Risk

Low — expected return when polling; handle by retrying or blocking.

What this means

ENOMSG (errno 42) is returned by msgrcv() when IPC_NOWAIT is set and no message of the requested type exists in the queue.

Why it happens
  1. 1Calling msgrcv() with IPC_NOWAIT and no matching message type in the queue
How to reproduce

Non-blocking message queue receive with no matching message.

trigger — this will error
trigger — this will error
// C: non-blocking msgrcv with no matching type
ssize_t n = msgrcv(msqid, &buf, sizeof(buf.mtext), 42, IPC_NOWAIT);
// Returns -1, errno = ENOMSG

expected output

msgrcv: No message of desired type (ENOMSG)

Fix

Use blocking call or check before receiving

WHEN When polling a message queue

Use blocking call or check before receiving
// Block until message arrives (remove IPC_NOWAIT)
ssize_t n = msgrcv(msqid, &buf, sizeof(buf.mtext), 42, 0);

Why this works

Without IPC_NOWAIT, msgrcv blocks until a matching message arrives.

Sources
Official documentation ↗

Linux Programmer Manual msgrcv(2)

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Linux / POSIX errors