Open System Services System Calls Reference Manual (G06.25+, H06.03+)
System Functions (k - m) msgrcv(2)
NAME
msgrcv - Receives a message from a message queue
LIBRARY
G-series native OSS processes: /G/system/sysnn/zossksrl
H-series OSS processes: /G/system/zdllnnn/zosskdll
SYNOPSIS
#include <sys/msg.h>
int msgrcv(
int msqid,
void *msgp,
size_t msgsz,
long int msgtyp,
int msgflg);
PARAMETERS
msqid Specifies the identifier of the message queue from which to read a message.
msgp Specifies a pointer to the msgbuf structure that is to receive the message. (See
the NOTES section.)
msgsz Specifies the maximum number of bytes allowed for the received message.
msgtyp Specifies the message type to read from the queue.
msgflg Specifies the action to be taken by the system if there are no msgtyp messages in
the queue. This parameter also specifies whether to truncate the message if its
length exceeds the value specified by msgsz.
DESCRIPTION
The msgrcv() function reads a message from the queue associated with the msqid parameter. It
returns the number of bytes in the received message.
The msgp parameter points to a user-defined msgbuf structure. The structure receives the mes-
sage read from the queue.
The msgsz parameter specifies the maximum size allowed for the received message. If the mes-
sage is longer than the value specified by the msgsz parameter, the system takes one of the fol-
lowing actions:
• If the MSG_NOERROR flag is used in the msgflg parameter, the system truncates the
message to msgsz bytes and discards the truncated portion without notifying the calling
process.
• If the MSG_NOERROR flag is not used in the msgflg parameter, the system returns an
errno value of [E2BIG] to the calling process and leaves the message in the queue.
The msgtyp parameter specifies the message type that the process wants to receive. Possible
values and their results are as follows:
0 (zero) The process receives the message at the head of the queue.
> 0 (positive) The process receives the first message of the requested message type.
527186-003 Hewlett-Packard Company 4−39