

msgsnd()               COHERENT System Call              msgsnd()




Send a message

#include <sys/msg.h>
mmssggssnndd(_m_s_q_i_d, _m_s_g_p, _m_s_g_s_z, _m_s_g_f_l_g)
iinntt _m_s_q_i_d, _m_s_g_s_z, _m_s_g_f_l_g; ssttrruucctt mmssggbbuuff *_m_s_g_p;

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 (_m_s_g_f_l_g & IIPPCC_NNOOWWAAIITT) is  true, the message is not sent and
   the calling process returns immediately.

*   If  (_m_s_g_f_l_g  &  IIPPCC_NNOOWWAAIITT)  is  false, the  calling  process
   suspends execution until one of the following occurs:

11. The condition responsible for the suspension no longer exists,
   in which case the message is sent.

22. msqid  is removed from  the system.  When  this occurs, msgsnd
   sets errno to EDOM and returns -1.

3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
   (EEAACCCCEESS).

*  mtype is less than one (EEIINNVVAALL).

*  The message cannot be sent  for one of the reasons cited above
   and (_m_s_g_f_l_g & IIPPCC_NNOOWWAAIITT) is true (EEAAGGAAIINN).

*  msgsz  is less  than zero  or greater than  the system-imposed
   limit (EEIINNVVAALL).

*  msgp points to an illegal address (EEFFAAUULLTT).

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  mmssgg  functions  are presently  im-
plemented  as a  device driver  rather than  as an  actual system
call.










COHERENT Lexicon                                           Page 2


