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 msgg);
PARAMETERS
msqid Species the identier of the message queue from which to read a message.
msgp Species a pointer to the msgbuf structure that is to receive the message. (See
the NOTES section.)
msgsz Species the maximum number of bytes allowed for the received message.
msgtyp Species the message type to read from the queue.
msgflg Species the action to be taken by the system if there are no msgtyp messages in
the queue. This parameter also species whether to truncate the message if its
length exceeds the value specied 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-dened msgbuf structure. The structure receives the mes-
sage read from the queue.
The msgsz parameter species the maximum size allowed for the received message. If the mes-
sage is longer than the value specied by the msgsz parameter, the system takes one of the fol-
lowing actions:
If the MSG_NOERROR ag is used in the msgg parameter, the system truncates the
message to msgsz bytes and discards the truncated portion without notifying the calling
process.
If the MSG_NOERROR ag is not used in the msgg parameter, the system returns an
errno value of [E2BIG] to the calling process and leaves the message in the queue.
The msgtyp parameter species 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 rst message of the requested message type.
527186-003 Hewlett-Packard Company 439