2 .\" Hey Emacs! This file is -*- nroff -*- source.
4 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH MQ_OPEN 3 2009-02-20 "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
74 Open the queue in nonblocking mode.
75 In circumstances where
79 would normally block, these functions instead fail with the error
83 Create the message queue if it does not exist.
84 The owner (user ID) of the message queue is set to the effective
85 user ID of the calling process.
86 The group ownership (group ID) is set to the effective group ID
87 of the calling process.
88 .\" In reality the file system IDs are used on Linux.
95 and a queue with the given
97 already exists, then fail with the error
104 then two additional arguments must be supplied.
107 argument specifies the permissions to be placed on the new queue,
110 (Symbolic definitions for the permissions bits can be obtained by including
112 The permissions settings are masked against the process umask.
115 argument specifies attributes for the queue.
121 is NULL, then the queue is created with implementation-defined
126 returns a message queue descriptor for use by other
127 message queue functions.
134 set to indicate the error.
138 The queue exists, but the caller does not have permission to
139 open it in the specified mode.
143 contained more than one slash.
144 .\" Note that this isn't consistent with the same case for sem_open()
153 but a queue with this
168 Both of these fields must be greater than zero.
169 In a process that is unprivileged (does not have the
173 must be less than or equal to the
177 must be less than or equal to the
180 In addition, even in a privileged process,
187 for details of these limits.)
190 The process already has the maximum number of files and
198 The system limit on the total number of open files and message queues
204 flag was not specified in
206 and no queue with this
212 was just "/" followed by no other characters.
213 .\" Note that this isn't consistent with the same case for sem_open()
219 Insufficient space for the creation of a new message queue.
220 This probably occurred because the
222 limit was encountered; see
227 In kernels before 2.6.14,
228 the process umask was not applied to the permissions specified in