1 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
2 .\" and Copyright 2004, 2005 Michael Kerrisk <mtk-manpages@gmx.net>
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" Modified Tue Oct 22 08:11:14 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
25 .\" Modified Sun Feb 18 01:59:29 2001 by Andries E. Brouwer <aeb@cwi.nl>
26 .\" Modified, 27 May 2004, Michael Kerrisk <mtk-manpages@gmx.net>
27 .\" Added notes on CAP_IPC_OWNER requirement
28 .\" Modified, 17 Jun 2004, Michael Kerrisk <mtk-manpages@gmx.net>
29 .\" Added notes on CAP_SYS_ADMIN requirement for IPC_SET and IPC_RMID
30 .\" Modified, 11 Nov 2004, Michael Kerrisk <mtk-manpages@gmx.net>
31 .\" Language and formatting clean-ups
32 .\" Added msqid_ds and ipc_perm structure definitions
33 .\" 2005-08-02, mtk: Added IPC_INFO, MSG_INFO, MSG_STAT descriptions
35 .TH MSGCTL 2 2004-11-10 "Linux 2.6.9" "Linux Programmer's Manual"
37 msgctl \- message control operations
41 #include <sys/types.h>
48 .BI "int msgctl(int " msqid ,
50 .BI "struct msqid_ds *" buf );
53 performs the control operation specified by
55 on the message queue with identifier
60 data structure is defined in <sys/msg.h> as follows:
65 struct ipc_perm msg_perm; /* Ownership and permissions
66 time_t msg_stime; /* Time of last msgsnd() */
67 time_t msg_rtime; /* Time of last msgrcv() */
68 time_t msg_ctime; /* Time of last change */
69 unsigned long __msg_cbytes; /* Current number of bytes in
70 queue (non-standard) */
71 msgqnum_t msg_qnum; /* Current number of messages
73 msglen_t msg_qbytes; /* Maximum number of bytes
75 pid_t msg_lspid; /* PID of last msgsnd() */
76 pid_t msg_lrpid; /* PID of last msgrcv() */
83 structure is defined in <sys/ipc.h> as follows
84 (the highlighted fields are settable using
90 key_t key; /* Key supplied to msgget() */
91 uid_t \fBuid\fP; /* Effective UID of owner */
92 gid_t \fBgid\fP; /* Effective GID of owner */
93 uid_t cuid; /* Effective UID of creator */
94 gid_t cgid; /* Effective GID of creator */
95 unsigned short \fBmode\fP; /* Permissions */
96 unsigned short seq; /* Sequence number */
106 Copy information from the kernel data structure associated with
110 structure pointed to by
112 The caller must have read permission on the message queue.
115 Write the values of some members of the
117 structure pointed to by
119 to the kernel data structure associated with this message queue,
123 The following members of the structure are updated:
127 and (the least significant 9 bits of)
129 The effective UID of the calling process must match the owner
132 .RI ( msg_perm.cuid )
133 of the message queue, or the caller must be privileged.
134 Appropriate privilege (Linux: the
136 capability) is required to raise the
138 value beyond the system parameter
142 Immediately remove the message queue,
143 awakening all waiting reader and writer processes (with an error
148 The calling process must have appropriate privileges
149 or its effective user ID must be either that of the creator or owner
150 of the message queue.
152 .BR IPC_INFO " (Linux specific)"
153 Returns information about system-wide message queue limits and
154 parameters in the structure pointed to by
156 This structure is of type
158 (thus, a cast is required),
161 if the _GNU_SOURCE feature test macro is defined:
166 int msgpool; /* Size in bytes of buffer pool used
167 to hold message data; unused */
168 int msgmap; /* Max. # of entries in message
170 int msgmax; /* Max. # of bytes that can be
171 written in a single message */
172 int msgmnb; /* Max. # of bytes that can be written to
173 queue; used to initialize msg_qbytes
174 during queue creation (msgget()) */
175 int msgmni; /* Max. # of message queues */
176 int msgssz; /* Message segment size; unused */
177 int msgtql; /* Max. # of messages on all queues
179 unsigned short int msgseg;
180 /* Max. # of segments; unused */
190 settings can be changed via
192 files of the same name; see
196 .BR MSG_INFO " (Linux specific)"
199 structure containing the same information as for
201 except that the following fields are returned with information
202 about system resources consumed by message queues: the
204 field returns the number of message queues that currently exist
207 field returns the total number of messages in all queues
208 on the system; and the
210 field returns the total number of bytes in all messages
211 in all queues on the system.
213 .BR MSG_STAT " (Linux specific)"
220 argument is not a queue identifier, but instead an index into
221 the kernel's internal array that maintains information about
222 all message queues on the system.
234 operation returns the index of the highest used entry in the
235 kernel's internal array recording information about all
237 (This information can be used with repeated
239 operations to obtain information about all queues on the system.)
242 operation returns the identifier of the queue whose index was given in
245 On error, \-1 is returned with
247 indicating the error.
251 is set to one of the following:
260 but the calling process does not have read permission on the message queue
262 and does not have the
273 but the address pointed to by
278 The message queue was removed.
287 operation, the index value specified in
289 referred to an array slot that is currently unused.
298 but the effective user ID of the calling process is not the creator
304 of the message queue,
305 and the process is not privileged (Linux: it does not have the
314 operations are used by the
316 program to provide information on allocated resources.
317 In the future these may modified or moved to a /proc file system
320 Various fields in the \fIstruct msqid_ds\fP were shorts under Linux 2.2
321 and have become longs under Linux 2.4. To take advantage of this,
322 a recompilation under glibc-2.1.91 or later should suffice.
323 (The kernel distinguishes old and new calls by an IPC_64 flag in
326 SVr4, SVID. SVID does not document the EIDRM error condition.
331 .BR capabilities (7),