COHERENT manpages
This page displays the COHERENT manpage for msgctl() [Message control operations].
List of available manpages
Index
msgctl() -- General Function (libc)
Message control operations
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
int msgctl(id, command, buffer)
int id; int command; struct msqid_ds *buffer;
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:
IPC_STAT 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.
IPC_SET 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.
IPC_RMID 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:
-> id is not a valid message-queue identifier (EINVAL).
-> command is not a valid command (EINVAL).
-> command equals IPC_STAT, but the owner of the calling process lacks
permission to execute this command (EACCES).
-> command equals IPC_RMID or IPC_SET, but the owner of the calling process
lacks permission to execute the command (EPERM).
-> A process owned by someone other than the superuser root attempted to
increase field msg_qbytes (EPERM).
-> buffer points to an illegal address (EFAULT).
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
libc,
msgget(),
msgrcv(),
msgsnd()
Notes
For information on other methods of interprocess communication, see the
Lexicon entries for semctl(), shmctl(), and libsocket.






