Open System Services System Calls Reference Manual (G06.25+, H06.03+)

msgrcv(2) OSS System Calls Reference Manual
< 0 (negative) The process receives the rst message of the lowest type on the queue. To qual-
ify as the lowest type, a messages type must be less than or equal to the absolute
value of the msgtyp parameter.
The msgg parameter species 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 specied, as follows:
If the IPC_NOWAIT ag is used, the function call returns immediately with the value -1
and errno is set to [ENOMSG].
If the IPC_NOWAIT ag 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 specied message queue identier 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 ag is dened in the sys/ipc.h header le.
The user-supplied msgbuf structure, used to store received messages, can be dened as follows:
struct msgbuf {
long int mtype;
char mtext[];
};
The mtype eld is set to the message type assigned by the sender.
The mtext eld is set to the message text. The message size is less than or equal to the value of
the msgsz parameter specied 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 eld. Also, the system updates the msqid_ds structure associated with the message
queue identier as follows:
Decrements the value in the msg_qnum eld by 1.
Decrements the value in the msg_cbytes eld by the message text size.
Sets the msg_lrpid eld to the OSS process ID of the calling process.
Sets the msg_rtime eld to the current time.
When the msgrcv() function fails, the value -1 is returned and errno is set to indicate the error.
440 Hewlett-Packard Company 527186-003