Reads a message from a message queue.
#include <sys/types.h> #include <sys/errno.h> #include <sys/ipc.h> #include <sys/msg.h>
int kmsgrcv (msqid, msgp, msgsz, msgtyp, msgflg, flags, bytes) int msqid; struct msgxbuf *msgp; or struct msgbuf *msgp; int msgsz; mtyp_t msgtyp; int msgflg; int flags; int *bytes;
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.
The kmsgrcv kernel service is part of Base Operating System (BOS) Runtime.
The msgrcv subroutine, msgxrcv subroutine.
Message Queue Kernel Services in AIX Kernel Extensions and Device Support Programming Concepts.
Understanding System Call Execution in AIX Kernel Extensions and Device Support Programming Concepts.