msgsnd() COHERENT System Call msgsnd()
Send a message
#include <sys/msg.h>
msgsnd(msqid, msgp, msgsz, msgflg)
int msqid, msgsz, msgflg; struct msgbuf *msgp;
The COHERENT system call msgsnd sends a message to the queue as-
sociated with the message queue identifier msqid. msgp points to
a structure that contains the message. This structure consists
of the following members:
long mtype; /* message type */
char mtext[]; /* message text */
mtype is a positive long integer that the receiving process uses
to select messages. mtext is a string that is msgsz bytes long.
msgsz can range from zero to a system-imposed limit as specified
in the kernel variable NMSC.
msgflg specifies the action to be taken if one or more of the
following are true:
* The number of bytes already on the queue is equal to
msg_qbytes.
* The number of messages on all queues system-wide equals the
system limit specified in the kernel variable NMSG.
msgflg can specify any of the following actions:
* If (msgflg & IPC_NOWAIT) is true, the message is not sent and
the calling process returns immediately.
* If (msgflg & IPC_NOWAIT) is false, the calling process
suspends execution until one of the following occurs:
1. The condition responsible for the suspension no longer exists,
in which case the message is sent.
2. msqid is removed from the system. When this occurs, msgsnd
sets errno to EDOM and returns -1.
3. The calling process receives a signal that is to be caught.
In this case, the message is not sent and the calling process
resumes execution in the manner prescribed in signal.
msgsnd fails and no message is sent if one or more of the
following are true:
* msqid is not a valid message queue identifier. msgsnd sets
errno to EINVAL.
COHERENT Lexicon Page 1
msgsnd() COHERENT System Call msgsnd()
* Operation permission is denied to the calling process
(EACCES).
* mtype is less than one (EINVAL).
* The message cannot be sent for one of the reasons cited above
and (msgflg & IPC_NOWAIT) is true (EAGAIN).
* msgsz is less than zero or greater than the system-imposed
limit (EINVAL).
* msgp points to an illegal address (EFAULT).
Upon successful completion, the following actions are taken with
respect to the data structure associated with msqid.
* msg_qnum is incremented by one.
* msg_lspid is set equal to the process ID of the calling
process.
* msg_stime is set equal to the current time.
***** Return Values *****
If msgsnd return because it has received a signal, it returns -1
and sets errno to EINTR. If it returns because msqid was removed
from the system, it returns -1 and sets errno to EDOM.
Upon successful completion, msgsnd returns zero. Otherwise, it
returns -1 and sets errno to an appropriate value.
***** Files *****
/usr/include/sys/ipc.h
/usr/include/sys/msg.h
/dev/msg
***** See Also *****
COHERENT system calls, msg, msgctl(), msgget(), msgrcv()
***** Notes *****
To improve portability, the msg functions are presently im-
plemented as a device driver rather than as an actual system
call.
COHERENT Lexicon Page 2