msgctl()" -- General Function (libc)" "
Message control operations
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
iinntt mmssggccttll((_i_d_, _c_o_m_m_a_n_d_, _b_u_f_f_e_r))
iinntt _i_d;; iinntt _c_o_m_m_a_n_d;; ssttrruucctt mmssqqiidd__ddss **_b_u_f_f_e_r;;
The function msgctl() controls the
COHERENT's system's messaging facility. This facility
permits processes to pass messages from one another.
Each message queue is controlled by a structure of type
msqid_ds, which is defined in header file
<sys/msg.h>. This structure points to
the first and last messages in the queue, gives the size of
the queue and the number of messages in the queue, and names
who can manipulate it and how. The messages themselves
consist of a linked list of structures of type
msg, which is also defined in
msg.h. When the function
msgget() creates a message queue, it
assigns to that queue an identification number and returns
that number to the calling process. For details on this
process, see the Lexicon entry for msgget().
id identifies the message queue to be manipulated.
This value must have been returned by a call to
msgget().
command names the operation that you want
msgctl() to perform.
msgctl() recognizes the following
commands:
- IIPPCC__SSTTAATT
- Copy the message-queue structure identified by
id into the structure pointed to by
buffer. This command lets you gather
information about a message queue without actually
manipulating the queue.
- IIPPCC__SSEETT
- This command sets permissions for this queue. It does
so by copying fields msg_perm.uid,
msg_perm.gid, msg_perm.mode
(low nine bits only), and msg_qbytes from
the message-queue structure point to by buffer to
structure identified by id. Only the superuser
root and the user who owns the process that
created structure id can execute this
command. Note that only the superuser can
raise the value of field msg_qbytes, which
gives the size of space occupied by the queue, in bytes.
- IIPPCC__RRMMIIDD
- Remove the structure identified by id,
and destroy its queue. Only the superuser
root and the user who owns the process that
created structure id do this.
If any of the following conditions occur,
msgctl() returns -1 and sets
error to the value in parentheses:
- +o
- id is not a valid message-queue identifier
(EEIINNVVAALL).
- +o
- command is not a valid command (EEIINNVVAALL).
- +o
- command equals IPC_STAT, but the
owner of the calling process lacks permission to execute
this command (EEAACCCCEESS).
- +o
- command equals IPC_RMID or
IPC_SET, but the owner of the calling process
lacks permission to execute the command (EEPPEERRMM).
- +o
- A process owned by someone other than the superuser
root attempted to increase field
msg_qbytes (EEPPEERRMM).
- +o
- buffer points to an illegal address (EEFFAAUULLTT).
If all went well, msgctl() returns zero.
Example
For an example of this function, see the Lexicon entry for
msgget().
Files
/usr/include/sys/ipc.h
/usr/include/sys/msg.h
See Also
Notes
For information on other methods of interprocess
communication, see the Lexicon entries for
semctl(), shmctl(), and
libsocket.