Reads a message from a message queue.
Item | Description |
---|---|
msqid | Specifies the message queue from which to read. |
msgp | Points to either an msgxbuf or an msgbuf structure where the message text is placed. The type of structure pointed to is determined by the values of the flags parameter. These structures are defined in the /usr/include/sys/msg.h file. |
msgsz | Specifies the maximum number of bytes of text to be received from the message queue. The received message is truncated to the size specified by the msgsz parameter if the message is longer than this size and MSG_NOERROR is set in the msgflg parameter. The truncated part of the message is lost and no indication of the truncation is given to the calling process. |
msgtyp | Specifies
the type of message requested as follows:
|
msgflg | Specifies a value of 0, or is constructed by logically ORing
one of several values:
|
flags | Specifies a value of 0 if a normal message receive is to be performed. If an extended message receive is to be performed, this flag should be set to an XMSG value. With this flag set, the kmsgrcv service functions as the msgxrcv subroutine would. Otherwise, the kmsgrcv service functions as the msgrcv subroutine would. |
bytes | Specifies a
reference parameter. This parameter contains
the number of message-text bytes read from the message queue upon
return from the kmsgrcv service. If the message is longer than the number of bytes specified by the msgsz parameter bytes but MSG_NOERROR is not set, then the kmsgrcv kernel service fails and returns an E2BIG return value. |
The kmsgrcv kernel service reads a message from the queue specified by the msqid parameter and stores the message into the structure pointed to by the msgp parameter. The kmsgrcv kernel service provides the same functions for user-mode processes in kernel mode as the msgrcv and msgxrcv subroutines perform for kernel processes or user-mode processes in user mode.
The kmsgrcv service can be called by a user-mode process in kernel mode or by a kernel process. A kernel process can also call the msgrcv and msgxrcv subroutines to provide the same functions.
The kmsgrcv kernel service can be called from the process environment only.
Item | Description |
---|---|
0 | Indicates a successful operation. |
EINVAL | Indicates that the ID specified by the msqid parameter is not a valid message queue ID. |
EACCES | Indicates that operation permission is denied to the calling process. |
EINVAL | Indicates that the value of the msgsz parameter is less than 0. |
E2BIG | Indicates that the message text is greater than the maximum length specified by the msgsz parameter and MSG_NOERROR is not set. |
ENOMSG | Indicates that the queue does not contain a message of the desired type and IPC_NOWAIT is set. |
EINTR | Indicates that the kmsgrcv service received a signal. |
EIDRM | Indicates that the message queue ID specified by the msqid parameter has been removed from the system. |