HP-UX Reference (11i v1 00/12) - 2 System Calls (vol 5)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man2/!!!intro.2
________________________________________________________________
___ ___
m
msgop(2) msgop(2)
NAME
msgsnd, msgrcv - message operations
SYNOPSIS
#include <sys/msg.h>
int msgsnd(
int msqid,
const void *msgp,
size_t msgsz,
int msgflg
);
int msgrcv(
int msqid,
void *msgp,
size_t msgsz,
long msgtyp,
int msgflg
);
DESCRIPTION
The msgsnd() system call sends a message to the queue associated with the message queue identifier
specified by msqid.
msgp points to a user-defined buffer that must contain first a field of type
long that specifies the type of
the message, followed by a data portion that will hold the data bytes of the message. The structure below
is an example of what this user-defined buffer might look like:
long mtype; /* message type */
char mtext[]; /* message text */
mtype is a positive integer that can be used by the receiving process for message selection (see
msgrcv()
below). mtext is any text of length msgsz bytes. msgsz can range from 0 to a system-imposed maximum.
msgflg specifies the action to be taken if one or more of the following is true:
The number of bytes already on the queue is equal to msg_qbytes (see message queue identifier
in glossary(9)).
The total number of messages on all queues system-wide is equal to the system-imposed limit.
These actions are as follows:
If (msgflg
& IPC_NOWAIT ) is true, the message is not sent and the calling process returns immedi-
ately.
If (msgflg & IPC_NOWAIT ) is false, the calling process suspends execution until one of the follow-
ing occurs:
The condition responsible for the suspension no longer exists, in which case the message is sent.
msqid is removed from the system (see msgctl(2)). When this occurs, errno is set to [EIDRM]
and a value of
-1 is returned.
The calling process receives a signal to be caught. In this case, the message is not sent 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 incremented by 1.
msg_lspid is set to the process ID of the calling process.
msg_stime is set to the current time.
The msgrcv() system call reads a message from the queue associated with the message queue identifier
specified by msqid and places it in the structure pointed to by msgp. This structure is composed of the fol-
lowing members:
Section 2188 1 HP-UX Release 11i: December 2000
___
___