HP-UX Reference (11i v3 07/02) - 2 System Calls (vol 5)

m
msgop(2) msgop(2)
long mtype; /* message type */
char mtext[]; /* message text */
mtype is the received message’s type as specified by the sending process. mtext is the text of the message.
msgsz specifies the size in bytes of mtext. The received message is truncated to msgsz bytes if it is larger
than msgsz and (msgflg
& MSG_NOERROR
) is true. 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:
msgtyp = 0 First message on the queue is received.
msgtyp > 0 First message of type msgtyp is received.
msgtyp < 0 First message of the lowest type that is less than or equal to the absolute value of msgtyp
is received.
msgflg specifies the action to be taken if a message of the desired type is not on the queue. These are as
follows:
If (msgflg
& IPC_NOWAIT
) is true, the calling process returns immediately with a value of -1 and
errno set to [ENOMSG].
If (msgflg & IPC_NOWAIT ) is false, the calling process suspends execution until one of the follow-
ing occurs:
A message of the desired type is placed on the queue.
msqid is removed from the system. When this occurs, errno is set to [EIDRM] and a value of
1 is returned.
The calling process receives a signal that is to be caught. In this case, a message is not received
and the calling process resumes execution in the manner prescribed in signal(5)).
Upon successful completion, the following actions are taken with respect to the data structure associated
with msqid.
msg_qnum is decremented by 1.
msg_lrpid is set to the process ID of the calling process.
msg_rtime is set to the current time.
RETURN VALUE
Upon successful completion, the return value is as follows:
msgsnd() returns a value of 0.
msgrcv() returns a value equal to the number of bytes actually placed into mtext.
Otherwise, a value of
-1 is returned and errno is set to indicate the error.
ERRORS
If msgrcv() fails, errno is set to one of the following values.
[E2BIG] mtext is greater than msgsz and (msgflg & MSG_NOERROR )isfalse.
[EACCES] Operation permission is denied to the calling process.
[EFAULT] msgp points to an illegal address. The reliable detection of this error is implementa-
tion dependent.
[EIDRM] The message queue identifier msqid has been removed from the system.
[EINTR] The function msgrcv() was interrupted by a signal.
[EINVAL] msqid is not a valid message queue identifier.
[EINVAL] msgsz is less than 0.
[ENOMSG] The queue does not contain a message of the desired type and (msgflg &
IPC_NOWAIT
) is true.
If msgsnd() fails, errno is set to one of the following values.
244 Hewlett-Packard Company 2 HP-UX 11i Version 3: February 2007