1 .\" Copyright (c) 2005 David Xu <davidxu@FreeBSD.org>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice(s), this list of conditions and the following disclaimer as
9 .\" the first lines of this file unmodified other than the possible
10 .\" addition of one or more copyright notices.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice(s), this list of conditions and the following disclaimer in
13 .\" the documentation and/or other materials provided with the
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17 .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
20 .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 .\" Portions of this text are reprinted and reproduced in electronic form
29 .\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
30 .\" Portable Operating System Interface (POSIX), The Open Group Base
31 .\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
32 .\" Electrical and Electronics Engineers, Inc and The Open Group. In the
33 .\" event of any discrepancy between this version and the original IEEE and
34 .\" The Open Group Standard, the original IEEE and The Open Group Standard is
35 .\" the referee document. The original Standard can be obtained online at
36 .\" http://www.opengroup.org/unix/online.html.
45 .Nd "open a message queue (REALTIME)"
51 .Fn mq_open "const char *name" "int oflag" "..."
55 system call establishes the connection between a process and a message queue
56 with a message queue descriptor.
57 It creates an open message queue
58 description that refers to the message queue, and a message queue descriptor
59 that refers to that open message queue description.
61 descriptor is used by other functions to refer to that message queue.
64 argument points to a string naming a message queue.
67 argument should conform to the construction rules for a pathname.
70 should begin with a slash character.
73 with the same value of
75 refers to the same message queue object, as long as that name has not been
79 argument is not the name of an existing message queue and creation is not
82 will fail and return an error.
86 argument requests the desired receive and/or send access to the message
88 The requested access permission to receive messages or send messages
89 would be granted if the calling process would be granted read or write access,
90 respectively, to an equivalently protected file.
94 is the bitwise-inclusive OR of values from the following list.
95 Applications should specify exactly one of the first three values (access
96 modes) below in the value of
98 .Bl -tag -width ".Dv O_NONBLOCK"
100 Open the message queue for receiving messages.
101 The process can use the
102 returned message queue descriptor with
106 A message queue may be open multiple times in the same or different processes
107 for receiving messages.
109 Open the queue for sending messages.
110 The process can use the returned
111 message queue descriptor with
115 A message queue may be open multiple times in the same or different processes
116 for sending messages.
118 Open the queue for both receiving and sending messages.
120 any of the functions allowed for
124 A message queue may be open multiple times in the same or different processes
125 for sending messages.
128 Any combination of the remaining flags may be specified in the value of
130 .Bl -tag -width ".Dv O_NONBLOCK"
132 Create a message queue.
133 It requires two additional arguments:
139 which is a pointer to an
144 has already been used to create a message queue that still exists, then
145 this flag has no effect, except as noted under
147 Otherwise, a message queue will be created without any messages
149 The user ID of the message queue will be set to the effective user ID
150 of the process, and the group ID of the message queue will be set to the
151 effective group ID of the process.
152 The permission bits of the message queue
153 will be set to the value of the
155 argument, except those set in the file mode creation mask of the process.
158 other than the file permission bits are specified, the effect is
164 the message queue is created with implementation-defined default message
168 and the calling process has the
169 appropriate privilege on name, the message queue
173 attributes will be set to the values of the corresponding members in the
175 structure referred to by
181 but the calling process does not have the appropriate privilege
184 function will fail and return an error without creating the message queue.
192 will fail if the message queue name exists.
194 Determines whether an
198 waits for resources or messages that are not currently available, or fails
212 system call does not add or remove messages from the queue.
215 implements message queue based on file descriptor.
217 is inherited by child after
219 The descriptor is closed in a new image after
225 system calls are supported for message queue descriptor.
227 Upon successful completion, the function returns a message queue
228 descriptor; otherwise, the function returns
229 .Po Vt mqd_t Pc Ns \-1
230 and sets the global variable
232 to indicate the error.
240 The message queue exists and the permissions specified by
242 are denied, or the message queue does not exist and permission to create the
243 message queue is denied.
248 are set and the named message queue already exists.
252 function was interrupted by a signal.
256 function is not supported for the given name.
269 was less than or equal to zero.
271 Too many message queue descriptors or file descriptors are currently in use
273 .It Bq Er ENAMETOOLONG
278 or a pathname component
282 Too many message queues are currently open in the system.
285 is not set and the named message queue does not exist.
287 There is insufficient space for the creation of the new message queue.
295 .Xr mq_timedreceive 3 ,
301 system call conforms to
306 message queues first appeared in
309 This implementation places strict requirements on the value of
311 it must begin with a slash
313 and contain no other slash characters.
315 Portions of this text are reprinted and reproduced in electronic form
316 from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
317 Portable Operating System Interface (POSIX), The Open Group Base
318 Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
319 Electrical and Electronics Engineers, Inc and The Open Group. In the
320 event of any discrepancy between this version and the original IEEE and
321 The Open Group Standard, the original IEEE and The Open Group Standard is
322 the referee document. The original Standard can be obtained online at
323 http://www.opengroup.org/unix/online.html.