The msgsnd() function shall send a message to the queue associated with the message queue identifier specified by
msqid.

The application shall ensure that the argument msgp points to a user-defined buffer that contains first a field of type
long specifying the type of the message, and then a data portion that holds the data bytes of the message. The structure
below is an example of what this user-defined buffer might look like:

ERRORS

The message cannot be sent for one of the reasons cited above and (msgflg & IPC_NOWAIT) is non-zero.

[EIDRM]

The message queue identifier msqid is removed from the system.

[EINTR]

The msgsnd() function was interrupted by a signal.

[EINVAL]

The value of msqid is not a valid message queue identifier, or the value of mtype is less than 1; or the value of
msgsz is less than 0 or greater than the system-imposed limit.

The following sections are informative.

EXAMPLES

Sending a Message

The following example sends a message to the queue identified by the msqid argument (assuming that value has previously
been set). This call specifies that an error should be reported if no message is available. The message size is calculated directly
using the sizeof operator.

APPLICATION USAGE

The POSIX Realtime Extension defines alternative interfaces for interprocess communication (IPC). Application developers who
need to use IPC should design their applications so that modules using the IPC routines described in XSI Interprocess Communication can be easily modified to use the alternative
interfaces.