1 .\" Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" Added correction due to Nick Duffek <nsd@bbc.com>, aeb, 960426
6 .\" Modified Wed Nov 6 04:00:31 1996 by Eric S. Raymond <esr@thyrsus.com>
7 .\" Modified, 8 Jan 2003, Michael Kerrisk, <mtk.manpages@gmail.com>
8 .\" Removed EIDRM from errors - that can't happen...
9 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
10 .\" Added notes on capability requirements
11 .\" Modified, 11 Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
12 .\" Language and formatting clean-ups
13 .\" Added notes on /proc files
15 .TH msgget 2 (date) "Linux man-pages (unreleased)"
17 msgget \- get a System V message queue identifier
20 .RI ( libc ", " \-lc )
23 .B #include <sys/msg.h>
25 .BI "int msgget(key_t " key ", int " msgflg );
30 system call returns the System\ V message queue identifier associated
34 It may be used either to obtain the identifier of a previously created
39 does not have the value
41 or to create a new set.
43 A new message queue is created if
51 no message queue with the given key
64 and a message queue already exists for
72 (This is analogous to the effect of the combination
77 Upon creation, the least significant bits of the argument
79 define the permissions of the message queue.
80 These permission bits have the same format and semantics
81 as the permissions specified for the
85 (The execute permissions are not used.)
87 If a new message queue is created,
88 then its associated data structure
92 is initialized as follows:
97 are set to the effective user ID of the calling process.
102 are set to the effective group ID of the calling process.
104 The least significant 9 bits of
106 are set to the least significant 9 bits of
118 is set to the current time.
121 is set to the system limit
124 If the message queue already exists the permissions are
125 verified, and a check is made to see if it is marked for
130 returns the message queue identifier (a nonnegative integer).
131 On failure, \-1 is returned, and
133 is set to indicate the error.
137 A message queue exists for
139 but the calling process does not have permission to access the queue,
140 and does not have the
142 capability in the user namespace that governs its IPC namespace.
150 but a message queue already exists for
154 No message queue exists for
162 A message queue has to be created but the system does not have enough
163 memory for the new data structure.
166 A message queue has to be created but the system limit for the maximum
167 number of message queues
171 POSIX.1-2001, POSIX.1-2008, SVr4.
174 isn't a flag field but a
177 If this special value is used for
179 the system call ignores everything but the least significant 9 bits of
181 and creates a new message queue (on success).
183 The following is a system limit on message queue resources affecting a
188 System-wide limit on the number of message queues.
190 .\" commit 0050ee059f7fc86b1df2527aaa14ed5dc72f9973
191 the default value for this limit was calculated using a formula
192 based on available system memory.
193 Since Linux 3.19, the default value is 32,000.
194 On Linux, this limit can be read and modified via
195 .IR /proc/sys/kernel/msgmni .
197 Until version 2.3.20, Linux would return
201 on a message queue scheduled for deletion.
205 was perhaps unfortunate,
207 would more clearly show its function.
213 .BR capabilities (7),