1 .\" $NetBSD: mq_open.3,v 1.1 2009/01/05 21:19:49 rmind Exp $
3 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
10 .Nd open a message queue (REALTIME)
16 .Fn mq_open "const char *name" "int oflag"
18 .Fn mq_open "const char *name" "int oflag" "mode_t mode" "struct mq_attr *attr"
22 function establishes the connection between a process and a message queue
23 with a message queue descriptor.
24 It creates an open message queue description that refers to the message
25 queue, and a message queue descriptor that refers to that open message
27 The message queue descriptor is used by other functions to refer to that
31 argument points to a string naming a message queue,
32 which should conform to the construction rules for a pathname.
35 should begin with a slash character.
38 with the same value of
40 will refer to the same message queue object,
41 as long as that name has not been removed.
45 the name of an existing message queue and creation is not requested,
47 fails and returns an error.
51 argument requests the desired receive and/or send access to the message queue.
52 The requested access permission to receive messages or send messages are
53 granted if the calling process would be granted read or write access,
54 respectively, to an equivalently protected file.
58 is the bitwise-inclusive OR of values from the following list.
59 Applications must specify exactly one of the first three values
60 (access modes) below in the value of
62 .Bl -tag -width ".Dv O_RDONLY"
64 Open the message queue for receiving messages.
65 The process can use the returned message queue descriptor with
70 Open the queue for sending messages.
71 The process can use the returned message queue descriptor with
76 Open the queue for both receiving and sending messages.
77 The process can use any of the functions allowed for
83 In all cases, a message queue may be open multiple times in the same
84 or different processes for sending/receiving messages.
86 Any combination of the remaining flags may be specified in the value of
88 .Bl -tag -width ".Dv O_RDONLY"
90 Create a message queue.
91 It requires two additional arguments:
97 has already been used to create a message queue that still exists,
98 then this flag will have no effect, except as noted under
100 Otherwise, a message queue will be created without any messages in it.
101 The user ID of the message queue will be set to the effective user ID
102 of the process, and the group ID of the message queue will be set to
103 the effective group ID of the process.
104 The permission bits of the message queue will be set to the value of the
106 argument, except those set in the file mode creation mask of
110 other than the file permission bits are specified, the effect
116 the message queue will be created with implementation-defined default
117 message queue attributes.
122 and the calling process has the appropriate privilege on
128 attributes will be set to the values of the corresponding members in the
130 structure referred to by
135 .No non- Ns Dv NULL ,
136 but the calling process does not have the
137 appropriate privilege on
141 function will fail and return an error without creating the message queue.
149 fails if the message queue
152 The check for the existence of the message queue and the creation of the
153 message queue if it does not exist will be atomic with respect to other
167 is not set, the result is undefined.
169 Determines whether an
173 waits for resources or messages that are not currently available,
174 or fails with errno set to
180 function does not add or remove messages from the queue.
186 system calls to the message queue descriptor are supported by
188 however, it is not portable.
190 Upon successful completion,
192 returns a message queue descriptor.
193 Otherwise, the function returns
195 \-1 and sets the global variable
197 to indicate the error.
204 The message queue exists and the permissions specified by
206 are denied, or the message queue does not exist and permission
207 to create the message queue is denied.
212 are set and the named message queue already exists.
216 function was interrupted by a signal.
220 function is not supported for the given name, or
232 was less than or equal to zero.
234 Too many message queue descriptors or file descriptors are currently
235 in use by this process.
236 .It Bq Er ENAMETOOLONG
241 or a pathname component is longer than
244 Too many message queues are currently open in the system.
247 is not set and the named message queue does not exist.
249 There is insufficient space for the creation of the new message queue.
260 This function conforms to the
264 This function first appeared in
267 Portions of this text are reprinted and reproduced in electronic form
268 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
269 -- Portable Operating System Interface (POSIX), The Open Group Base
270 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
271 Electrical and Electronics Engineers, Inc and The Open Group.
273 event of any discrepancy between this version and the original IEEE and
274 The Open Group Standard, the original IEEE and The Open Group Standard
275 is the referee document.
276 The original Standard can be obtained online at
277 http://www.opengroup.org/unix/online.html .