1 .\" Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
3 .\" %%%LICENSE_START(VERBATIM)
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.
25 .\" Added correction due to Nick Duffek <nsd@bbc.com>, aeb, 960426
26 .\" Modified Wed Nov 6 04:00:31 1996 by Eric S. Raymond <esr@thyrsus.com>
27 .\" Modified, 8 Jan 2003, Michael Kerrisk, <mtk.manpages@gmail.com>
28 .\" Removed EIDRM from errors - that can't happen...
29 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
30 .\" Added notes on capability requirements
31 .\" Modified, 11 Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
32 .\" Language and formatting clean-ups
33 .\" Added notes on /proc files
35 .TH MSGGET 2 2012-05-31 "Linux" "Linux Programmer's Manual"
37 msgget \- get a System V message queue identifier
40 .B #include <sys/types.h>
41 .B #include <sys/ipc.h>
42 .B #include <sys/msg.h>
44 .BI "int msgget(key_t " key ", int " msgflg );
49 system call returns the System V message queue identifier associated
53 A new message queue is created if
61 no message queue with the given key
74 and a message queue already exists for
82 (This is analogous to the effect of the combination
87 Upon creation, the least significant bits of the argument
89 define the permissions of the message queue.
90 These permission bits have the same format and semantics
91 as the permissions specified for the
95 (The execute permissions are not used.)
97 If a new message queue is created,
98 then its associated data structure
102 is initialized as follows:
107 are set to the effective user ID of the calling process.
112 are set to the effective group ID of the calling process.
114 The least significant 9 bits of
116 are set to the least significant 9 bits of
128 is set to the current time.
131 is set to the system limit
134 If the message queue already exists the permissions are
135 verified, and a check is made to see if it is marked for
138 If successful, the return value will be the message queue identifier (a
139 nonnegative integer), otherwise \-1
142 indicating the error.
146 is set to one of the following values:
149 A message queue exists for
151 but the calling process does not have permission to access the queue,
152 and does not have the
157 A message queue exists for
167 No message queue exists for
175 A message queue has to be created but the system does not have enough
176 memory for the new data structure.
179 A message queue has to be created but the system limit for the maximum
180 number of message queues
190 isn't required on Linux or by any version of POSIX.
192 some old implementations required the inclusion of these header files,
193 and the SVID also documented their inclusion.
194 Applications intended to be portable to such old systems may need
195 to include these header files.
196 .\" Like Linux, the FreeBSD man pages still document
197 .\" the inclusion of these header files.
200 isn't a flag field but a
203 If this special value is used for
205 the system call ignores everything but the least significant 9 bits of
207 and creates a new message queue (on success).
209 The following is a system limit on message queue resources affecting a
214 System wide maximum number of message queues: policy
216 (on Linux, this limit can be read and modified via
217 .IR /proc/sys/kernel/msgmni ).
219 Until version 2.3.20 Linux would return
223 on a message queue scheduled for deletion.
227 was perhaps unfortunate,
229 would more clearly show its function.
235 .BR capabilities (7),
239 This page is part of release 3.65 of the Linux
242 A description of the project,
243 and information about reporting bugs,
245 \%http://www.kernel.org/doc/man\-pages/.