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"
19 .Fn mq_open "const char *name" "int oflag" "mode_t mode" "struct mq_attr *attr"
23 function establishes the connection between a process and a message queue
24 with a message queue descriptor.
25 It creates an open message queue description that refers to the message
26 queue, and a message queue descriptor that refers to that open message
28 The message queue descriptor is used by other functions to refer to that
32 argument points to a string naming a message queue,
33 which should conform to the construction rules for a pathname.
36 should begin with a slash character.
39 with the same value of
41 will refer to the same message queue object,
42 as long as that name has not been removed.
46 the name of an existing message queue and creation is not requested,
48 fails and returns an error.
52 argument requests the desired receive and/or send access to the message queue.
53 The requested access permission to receive messages or send messages are
54 granted if the calling process would be granted read or write access,
55 respectively, to an equivalently protected file.
59 is the bitwise-inclusive OR of values from the following list.
60 Applications must specify exactly one of the first three values
61 (access modes) below in the value of
63 .Bl -tag -width ".Dv O_RDONLY"
65 Open the message queue for receiving messages.
66 The process can use the returned message queue descriptor with
71 Open the queue for sending messages.
72 The process can use the returned message queue descriptor with
77 Open the queue for both receiving and sending messages.
78 The process can use any of the functions allowed for
84 In all cases, a message queue may be open multiple times in the same
85 or different processes for sending/receiving messages.
87 Any combination of the remaining flags may be specified in the value of
89 .Bl -tag -width ".Dv O_RDONLY"
91 Create a message queue.
92 It requires two additional arguments:
98 has already been used to create a message queue that still exists,
99 then this flag will have no effect, except as noted under
101 Otherwise, a message queue will be created without any messages in it.
102 The user ID of the message queue will be set to the effective user ID
103 of the process, and the group ID of the message queue will be set to
104 the effective group ID of the process.
105 The permission bits of the message queue will be set to the value of the
107 argument, except those set in the file mode creation mask of
111 other than the file permission bits are specified, the effect
117 the message queue will be created with implementation-defined default
118 message queue attributes.
123 and the calling process has the appropriate privilege on
129 attributes will be set to the values of the corresponding members in the
131 structure referred to by
136 .No non- Ns Dv NULL ,
137 but the calling process does not have the
138 appropriate privilege on
142 function will fail and return an error without creating the message queue.
150 fails if the message queue
153 The check for the existence of the message queue and the creation of the
154 message queue if it does not exist will be atomic with respect to other
168 is not set, the result is undefined.
170 Determines whether an
174 waits for resources or messages that are not currently available,
175 or fails with errno set to
181 function does not add or remove messages from the queue.
187 system calls to the message queue descriptor are supported by
189 however, it is not portable.
191 Upon successful completion,
193 returns a message queue descriptor.
194 Otherwise, the function returns
196 \-1 and sets the global variable
198 to indicate the error.
205 The message queue exists and the permissions specified by
207 are denied, or the message queue does not exist and permission
208 to create the message queue is denied.
213 are set and the named message queue already exists.
217 function was interrupted by a signal.
221 function is not supported for the given name, or
233 was less than or equal to zero.
235 Too many message queue descriptors or file descriptors are currently
236 in use by this process.
237 .It Bq Er ENAMETOOLONG
242 or a pathname component is longer than
245 Too many message queues are currently open in the system.
248 is not set and the named message queue does not exist.
250 There is insufficient space for the creation of the new message queue.
261 This function conforms to the
265 This function first appeared in
268 Portions of this text are reprinted and reproduced in electronic form
269 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
270 -- Portable Operating System Interface (POSIX), The Open Group Base
271 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
272 Electrical and Electronics Engineers, Inc and The Open Group.
274 event of any discrepancy between this version and the original IEEE and
275 The Open Group Standard, the original IEEE and The Open Group Standard
276 is the referee document.
277 The original Standard can be obtained online at
278 http://www.opengroup.org/unix/online.html .