mmssggssnndd() -- General Function (libc)

Send a message
#iinncclluuddee <ssyyss/ttyyppeess.hh>
#iinncclluuddee <ssyyss/iippcc.hh>
#iinncclluuddee <ssyyss/mmssgg.hh>
mmssggssnndd(_i_d, _b_u_f_f_e_r, _s_i_z_e, _f_l_a_g)
iinntt _i_d, _s_i_z_e, _f_l_a_g; lloonngg *_b_u_f_f_e_r;

The  function mmssggssnndd()  inserts a  message into  the queue  associated with
identifier _i_d.

_b_u_f_f_e_r points to  a user-defined buffer that holds a  code that defines the
type of the message, and the  text of the message.  _b_u_f_f_e_r can be described
by a structure something like the following (if we pretend mmtteexxtt[] is legal
C):

struct msgbuf {
     long mtype;            /* message type */
     char mtext[];          /* message text */
};

Field mmttyyppee is a positive long  integer that gives the type of message this
is.  Function mmssggrrccvv() examines this field to see if this message is of the
type that it  seeks.  The text of the message  immediately follows mmttyyppee in
memory, for _s_i_z_e  bytes.  _s_i_z_e can range from zero  to a maximum defined in
the kernel variable NNMMSSCC.

If any of the following error conditions occurs, mmssggssnndd() does not send the
message, sets eerrrrnnoo to the value given in parentheses, and returns -1:

-> _i_d is not a valid message queue identifier (EEIINNVVAALL).

-> The calling  process does not  have permission to  manipulate this queue
   (EEAACCCCEESS).

-> Field  mmttyyppee in  the structure  pointed to  by _b_u_f_f_e_r  is less  than one
   (EEIINNVVAALL).

-> _s_i_z_e  is  less  than  zero  or  greater than  the  system-imposed  limit
   (EEIINNVVAALL).

-> _b_u_f_f_e_r points to an illegal address (EEFFAAUULLTT).

Sending a  message may exceed  a system-defined limit.  There  are two such
limits: one limits the size of a queue, and the other sets the total number
of messages  available to your system.   The maximum size of  this queue is
given in the field mmssgg_qqbbyytteess  of the structure mmssqqiidd_ddss that controls that
queue.  If issuing  a message _s_i_z_e bytes long would  push the total size of
the queue's  messages past the  value of mmssgg_qqbbyytteess, then  an error occurs.
Likewise, an  error occurs if the system already  holds the maximum maximum
number of message available to it, as set by the kernel variable NNMMSSGG.

_f_l_a_g indicates how mmssggssnndd() is to  react to either of the above conditions.
If _f_l_a_g  is OR'd to  include value IIPPCC_NNOOWWAAIITT,  then mmssggssnndd() reacts  as it
does with any other error: it does not send the message, it returns -1, and
it sets eerrrrnnoo to an appropriate value (in this case, EEAAGGAAIINN).  If, however,
_f_l_a_g is  _n_o_t OR'd to include  IIPPCC_NNOOWWAAIITT, then mmssggssnndd() waits  until any of
the following happens:

11. The error condition resolves.   In this case, mmssggssnndd() sends the message
   and returns normally.

22. The message queue identified by _i_d  is removed from the system.  In this
   case, mmssggssnndd() does not send the message; it sets eerrrrnnoo to EEIIDDRRMM; and it
   returns -1.

33. The process that issued the call to mmssggssnndd() receives a signal.  In this
   case,  mmssggssnndd() does  not send  the  message, sets  eerrrrnnoo to  EEIINNTTRR, and
   returns -1.   The calling process then executes  the action requested by
   the signal.   For information on the behavior  that each signal invokes,
   see the Lexicon entry for ssiiggnnaall().

mmssggssnndd()  successfully  sends  a message,  returns  zero  and modifies  the
message queue in the following manner:

-> It increments by one the value in field mmssgg_qqnnuumm.

-> It sets field mmssgg_llssppiidd to the process ID of the calling process.

-> It sets mmssgg_ssttiimmee to the current time.

_E_x_a_m_p_l_e
For an example of this function, see the Lexicon entry for mmssggggeett().

_F_i_l_e_s
/uussrr/iinncclluuddee/ssyyss/iippcc.hh
/uussrr/iinncclluuddee/ssyyss/mmssgg.hh

_S_e_e _A_l_s_o
lliibbcc, mmssggccttll(), mmssggggeett(), mmssggrrccvv()
