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 2021-03-22 "Linux" "Linux Programmer's Manual"
37 msgget \- get a System V message queue identifier
40 .B #include <sys/msg.h>
42 .BI "int msgget(key_t " key ", int " msgflg );
47 system call returns the System\ V message queue identifier associated
51 It may be used either to obtain the identifier of a previously created
56 does not have the value
58 or to create a new set.
60 A new message queue is created if
68 no message queue with the given key
81 and a message queue already exists for
89 (This is analogous to the effect of the combination
94 Upon creation, the least significant bits of the argument
96 define the permissions of the message queue.
97 These permission bits have the same format and semantics
98 as the permissions specified for the
102 (The execute permissions are not used.)
104 If a new message queue is created,
105 then its associated data structure
109 is initialized as follows:
114 are set to the effective user ID of the calling process.
119 are set to the effective group ID of the calling process.
121 The least significant 9 bits of
123 are set to the least significant 9 bits of
135 is set to the current time.
138 is set to the system limit
141 If the message queue already exists the permissions are
142 verified, and a check is made to see if it is marked for
147 returns the message queue identifier (a nonnegative integer).
148 On failure, \-1 is returned, and
150 is set to indicate the error.
154 A message queue exists for
156 but the calling process does not have permission to access the queue,
157 and does not have the
159 capability in the user namespace that governs its IPC namespace.
167 but a message queue already exists for
171 No message queue exists for
179 A message queue has to be created but the system does not have enough
180 memory for the new data structure.
183 A message queue has to be created but the system limit for the maximum
184 number of message queues
188 POSIX.1-2001, POSIX.1-2008, SVr4.
191 isn't a flag field but a
194 If this special value is used for
196 the system call ignores everything but the least significant 9 bits of
198 and creates a new message queue (on success).
200 The following is a system limit on message queue resources affecting a
205 System-wide limit on the number of message queues.
207 .\" commit 0050ee059f7fc86b1df2527aaa14ed5dc72f9973
208 the default value for this limit was calculated using a formula
209 based on available system memory.
210 Since Linux 3.19, the default value is 32,000.
211 On Linux, this limit can be read and modified via
212 .IR /proc/sys/kernel/msgmni .
214 Until version 2.3.20, Linux would return
218 on a message queue scheduled for deletion.
222 was perhaps unfortunate,
224 would more clearly show its function.
230 .BR capabilities (7),