1 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Modified Tue Oct 22 08:11:14 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
24 .\" Modified Sun Feb 18 01:59:29 2001 by Andries E. Brouwer <aeb@cwi.nl>
25 .\" Modified, 27 May 2004, Michael Kerrisk <mtk-manpages@gmx.net>
26 .\" Added notes on CAP_IPC_OWNER requirement
27 .\" Modified, 17 Jun 2004, Michael Kerrisk <mtk-manpages@gmx.net>
28 .\" Added notes on CAP_SYS_ADMIN requirement for IPC_SET and IPC_RMID
29 .\" Modified, 11 Nov 2004, Michael Kerrisk <mtk-manpages@gmx.net>
30 .\" Language and formatting clean-ups
31 .\" Added msqid_ds and ipc_perm structure definitions
33 .TH MSGCTL 2 2004-11-10 "Linux 2.6.9" "Linux Programmer's Manual"
35 msgctl \- message control operations
39 #include <sys/types.h>
46 .BI "int msgctl(int " msqid ,
48 .BI "struct msqid_ds *" buf );
51 performs the control operation specified by
53 on the message queue with identifier
58 data structure is defined in <sys/msg.h> as follows:
63 struct ipc_perm msg_perm; /* Ownership and permissions
64 time_t msg_stime; /* Time of last msgsnd() */
65 time_t msg_rtime; /* Time of last msgrcv() */
66 time_t msg_ctime; /* Time of last change */
67 unsigned long __msg_cbytes; /* Current number of bytes in
68 queue (non-standard) */
69 msgqnum_t msg_qnum; /* Current number of messages
71 msglen_t msg_qbytes; /* Maximum number of bytes
73 pid_t msg_lspid; /* PID of last msgsnd() */
74 pid_t msg_lrpid; /* PID of last msgrcv() */
82 structure is defined in <sys/ipc.h> as follows
83 (the highlighted fields are settable using
89 key_t key; /* Key supplied to msgget() */
90 uid_t \fBuid\fP; /* Effective UID of owner */
91 gid_t \fBgid\fP; /* Effective GID of owner */
92 uid_t cuid; /* Effective UID of creator */
93 gid_t cgid; /* Effective GID of creator */
94 unsigned short \fBmode\fP; /* Permissions */
95 unsigned short seq; /* Sequence number */
105 Copy information from the kernel data structure associated with
109 structure pointed to by
111 The caller must have read permission on the message queue.
114 Write the values of some members of the
116 structure pointed to by
118 to the kernel data structure associated with this message queue,
122 The following members of the structure are updated:
126 and (the least significant 9 bits of)
128 The effective UID of the calling process must match the owner
131 .RI ( msg_perm.cuid )
132 of the message queue, or the caller must be privileged.
133 Appropriate privilege (Linux: the
135 capability) is required to raise the
137 value beyond the system parameter
141 Immediately remove the message queue,
142 awakening all waiting reader and writer processes (with an error
147 The calling process must have appropriate privileges
148 or its effective user\-ID must be either that of the creator or owner
149 of the message queue.
151 On success, the return value will be 0
155 indicating the error.
159 is set to one of the following:
168 but the calling process does not have read permission on the message queue
170 and does not have the
181 but the address pointed to by
186 The message queue was removed.
201 but the effective user ID of the calling process is not the creator
207 of the message queue,
208 and the process is not privileged (Linux: it does not have the
212 Various fields in the \fIstruct msqid_ds\fP were shorts under Linux 2.2
213 and have become longs under Linux 2.4. To take advantage of this,
214 a recompilation under glibc-2.1.91 or later should suffice.
215 (The kernel distinguishes old and new calls by an IPC_64 flag in
218 SVr4, SVID. SVID does not document the EIDRM error condition.