2 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH MQ_OPEN 3 2014-12-31 "Linux" "Linux Programmer's Manual"
28 mq_open \- open a message queue
31 .BR "#include <fcntl.h>" " /* For O_* constants */"
32 .BR "#include <sys/stat.h>" " /* For mode constants */"
33 .B #include <mqueue.h>
35 .BI "mqd_t mq_open(const char *" name ", int " oflag );
36 .BI "mqd_t mq_open(const char *" name ", int " oflag ", mode_t " mode ,
37 .BI " struct mq_attr *" attr );
40 Link with \fI\-lrt\fP.
43 creates a new POSIX message queue or opens an existing queue.
44 The queue is identified by
46 For details of the construction of
53 argument specifies flags that control the operation of the call.
54 (Definitions of the flags values can be obtained by including
56 Exactly one of the following must be specified in
60 Open the queue to receive messages only.
63 Open the queue to send messages only.
66 Open the queue to both send and receive messages.
68 Zero or more of the following flags can additionally be
73 .BR O_CLOEXEC " (since Linux 2.6.26)"
74 .\" commit 269f21344b23e552c21c9e2d7ca258479dcd7a0a
75 Set the close-on-exec flag for the message queue descriptor.
78 for a discussion of why this flag is useful.
81 Create the message queue if it does not exist.
82 The owner (user ID) of the message queue is set to the effective
83 user ID of the calling process.
84 The group ownership (group ID) is set to the effective group ID
85 of the calling process.
86 .\" In reality the filesystem IDs are used on Linux.
93 and a queue with the given
95 already exists, then fail with the error
99 Open the queue in nonblocking mode.
100 In circumstances where
104 would normally block, these functions instead fail with the error
111 then two additional arguments must be supplied.
114 argument specifies the permissions to be placed on the new queue,
117 (Symbolic definitions for the permissions bits can be obtained by including
119 The permissions settings are masked against the process umask.
123 argument specifies attributes for the queue.
129 is NULL, then the queue is created with implementation-defined
133 files can be used to control these defaults; see
139 returns a message queue descriptor for use by other
140 message queue functions.
147 set to indicate the error.
151 The queue exists, but the caller does not have permission to
152 open it in the specified mode.
156 contained more than one slash.
157 .\" Note that this isn't consistent with the same case for sem_open()
166 but a queue with this
181 Both of these fields must be greater than zero.
182 In a process that is unprivileged (does not have the
186 must be less than or equal to the
190 must be less than or equal to the
193 In addition, even in a privileged process,
200 for details of these limits.)
203 The process already has the maximum number of files and
211 The system limit on the total number of open files and message queues
217 flag was not specified in
219 and no queue with this
225 was just "/" followed by no other characters.
226 .\" Note that this isn't consistent with the same case for sem_open()
232 Insufficient space for the creation of a new message queue.
233 This probably occurred because the
235 limit was encountered; see
238 .SS Multithreading (see pthreads(7))
241 function is thread-safe.
245 In kernels before 2.6.14,
246 the process umask was not applied to the permissions specified in
257 This page is part of release 3.79 of the Linux
260 A description of the project,
261 information about reporting bugs,
262 and the latest version of this page,
264 \%http://www.kernel.org/doc/man\-pages/.