Open System Services System Calls Reference Manual (G06.25+, H06.03+)
msgrcv(2) OSS System Calls Reference Manual
< 0 (negative) The process receives the first message of the lowest type on the queue. To qual-
ify as the lowest type, a message’s type must be less than or equal to the absolute
value of the msgtyp parameter.
The msgflg parameter specifies the action that the system should take if the queue does not con-
tain a message of the requested type. Either of two system actions can be specified, as follows:
• If the IPC_NOWAIT flag is used, the function call returns immediately with the value -1
and errno is set to [ENOMSG].
• If the IPC_NOWAIT flag is not used, the system suspends the calling process. The pro-
cess remains suspended until one of the following occurs:
— A message of the requested type appears in the queue. In this case, the system
wakes the process to receive the message.
— The specified message queue identifier is removed from the system. In this case,
the system sets errno to [EIDRM] and returns the value -1 to the calling process.
— The process catches a signal. In this case, the process does not receive the mes-
sage; instead, it resumes execution as directed by a sigaction() function call.
Message Queue Use Between Environments
Guardian processes cannot use OSS functions to access OSS message queues. If called from a
Guardian process, the function call fails and errno is set to [ENOTOSS].
NOTES
The IPC_NOWAIT flag is defined in the sys/ipc.h header file.
The user-supplied msgbuf structure, used to store received messages, can be defined as follows:
struct msgbuf {
long int mtype;
char mtext[];
};
The mtype field is set to the message type assigned by the sender.
The mtext field is set to the message text. The message size is less than or equal to the value of
the msgsz parameter specified in the last successful call to msgrcv().
RETURN VALUES
Upon successful completion, the msgrcv() function returns the number of bytes actually stored
in the mtext field. Also, the system updates the msqid_ds structure associated with the message
queue identifier as follows:
• Decrements the value in the msg_qnum field by 1.
• Decrements the value in the msg_cbytes field by the message text size.
• Sets the msg_lrpid field to the OSS process ID of the calling process.
• Sets the msg_rtime field to the current time.
When the msgrcv() function fails, the value -1 is returned and errno is set to indicate the error.
4−40 Hewlett-Packard Company 527186-003