9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man3c / mq_open.3c
blobf393b6f06d7245b84ebc3aa84f2cb1cf7ee807ef
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
45 .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved
46 .\"
47 .TH MQ_OPEN 3C "Feb 5, 2008"
48 .SH NAME
49 mq_open \- open a message queue
50 .SH SYNOPSIS
51 .LP
52 .nf
53 #include <mqueue.h>
55 \fBmqd_t\fR \fBmq_open\fR(\fBconst char *\fR\fIname\fR, \fBint\fR \fIoflag\fR,
56      \fB/* unsigned long\fR \fImode\fR, \fBmq_attr\fR \fIattr\fR */  ...);
57 .fi
59 .SH DESCRIPTION
60 .sp
61 .LP
62 The \fBmq_open()\fR function establishes the connection between a process and a
63 message queue with a message queue descriptor. It creates a open message queue
64 description that refers to the message queue, and a message queue descriptor
65 that refers to that open message queue description. The message queue
66 descriptor is used by other functions to refer to that message queue.
67 .sp
68 .LP
69 The \fIname\fR argument points to a string naming a message queue. The
70 \fIname\fR argument must conform to the construction rules for a  path-name. If
71 \fIname\fR is not the name of an existing message queue and its creation is not
72 requested, \fBmq_open()\fR fails and returns an error. The first character of
73 \fIname\fR must be a slash  (\fB/\fR) character and the remaining characters of
74 \fIname\fR cannot include any slash characters.  For maximum portability,
75 \fIname\fR should include no more than 14 characters, but this limit is not
76 enforced.
77 .sp
78 .LP
79 The \fIoflag\fR argument requests the desired receive and/or send access to the
80 message queue. The requested access permission to receive messages or send
81 messages is granted if the calling process would be granted read or write
82 access, respectively, to a file with the equivalent permissions.
83 .sp
84 .LP
85 The value of \fIoflag\fR is the bitwise inclusive \fBOR\fR of values from the
86 following list. Applications must specify exactly one of the first three values
87 (access modes) below in the value of \fIoflag\fR:
88 .sp
89 .ne 2
90 .na
91 \fB\fBO_RDONLY\fR \fR
92 .ad
93 .RS 13n
94 Open the message queue for receiving messages. The process can use the returned
95 message queue descriptor with \fBmq_receive\fR(3C), but not \fBmq_send\fR(3C).
96 A message queue may be open multiple times in the same or different processes
97 for receiving messages.
98 .RE
101 .ne 2
103 \fB\fBO_WRONLY\fR \fR
105 .RS 13n
106 Open the queue for sending messages. The process can use the returned message
107 queue descriptor with \fBmq_send\fR(3C) but not \fBmq_receive\fR(3C). A message
108 queue may be open multiple times in the same or different processes for sending
109 messages.
113 .ne 2
115 \fB\fBO_RDWR\fR \fR
117 .RS 13n
118 Open the queue for both receiving and sending messages. The process can use any
119 of the functions allowed for \fBO_RDONLY\fR and \fBO_WRONLY\fR. A message queue
120 may be open multiple times in the same or different processes for sending
121 messages.
126 Any combination of the remaining flags may additionally be specified in the
127 value of \fIoflag\fR:
129 .ne 2
131 \fB\fBO_CREAT\fR \fR
133 .RS 15n
134 This option is used to create a message queue, and it requires two additional
135 arguments: \fImode\fR, which is of type \fBmode_t\fR, and  \fIattr\fR, which is
136 pointer to a \fBmq_attr\fR structure. If the pathname, \fIname\fR, has already
137 been used to create a message queue that still exists, then this flag has no
138 effect, except as noted under \fBO_EXCL\fR (see below). Otherwise, a message
139 queue is created without any messages in it.
141 The user ID of the message queue is set to the effective user ID of process,
142 and the group ID of the message queue is set to the effective group ID of the
143 process. The file permission bits are set to the value of \fImode\fR, and
144 modified by clearing all bits set in the file mode creation mask of the process
145 (see \fBumask\fR(2)).
147 If \fIattr\fR is non-\fINULL\fR and the calling process has the appropriate
148 privilege on \fIname\fR, the message queue \fImq_maxmsg\fR and \fImq_msgsize\fR
149 attributes are set to the values of the corresponding members in the
150 \fBmq_attr\fR structure referred to by \fIattr\fR. If \fIattr\fR is
151 non-\fINULL\fR, but the calling process does not have the appropriate privilege
152 on \fIname\fR, the \fBmq_open()\fR function fails and returns an error without
153 creating the message queue.
157 .ne 2
159 \fB\fBO_EXCL\fR \fR
161 .RS 15n
162 If both \fBO_EXCL\fR and \fBO_CREAT\fR are set, \fBmq_open()\fR will fail if
163 the message queue \fIname\fR exists. The check for the existence of the message
164 queue and the creation of the message queue if it does not exist are atomic
165 with respect to other processes executing \fBmq_open()\fR naming the same
166 \fIname\fR with both \fBO_EXCL\fR and \fBO_CREAT\fR set.  If \fBO_EXCL\fR and
167 \fBO_CREAT\fR are not set, the result is undefined.
171 .ne 2
173 \fB\fBO_NONBLOCK\fR \fR
175 .RS 15n
176 The setting of this flag is associated with the open message queue description
177 and determines whether a \fBmq_send\fR(3C) or \fBmq_receive\fR(3C) waits for
178 resources or messages that are not currently available, or fails with
179 \fBerrno\fR set to \fBEAGAIN\fR. See \fBmq_send\fR(3C) and \fBmq_receive\fR(3C)
180 for details.
183 .SH RETURN VALUES
186 Upon successful completion, \fBmq_open()\fR returns a message queue descriptor;
187 otherwise the function returns \fB(mqd_t)\(mi1\fR and sets \fBerrno\fR to
188 indicate the error condition.
189 .SH ERRORS
192 The  \fBmq_open()\fR function will fail if:
194 .ne 2
196 \fB\fBEACCES\fR \fR
198 .RS 17n
199 The message queue exists and the permissions specified by \fIoflag\fR are
200 denied, or the message queue does not exist and permission to create the
201 message queue is denied.
205 .ne 2
207 \fB\fBEEXIST\fR \fR
209 .RS 17n
210 \fBO_CREAT\fR and \fBO_EXCL\fR are set and the named message queue already
211 exists.
215 .ne 2
217 \fB\fBEINTR\fR \fR
219 .RS 17n
220 The \fBmq_open()\fR operation was interrupted by a signal.
224 .ne 2
226 \fB\fBEINVAL\fR \fR
228 .RS 17n
229 The \fBmq_open()\fR operation is not supported for the given name, or
230 \fBO_CREAT\fR was specified in \fIoflag\fR, the value of \fIattr\fR is not
231 \fINULL,\fR and either \fBmq_maxmsg\fR or \fBmq_msgsize\fR was less than or
232 equal to zero.
236 .ne 2
238 \fB\fBEMFILE\fR \fR
240 .RS 17n
241 The number of open message queue descriptors in this process exceeds
242 \fBMQ_OPEN_MAX,\fR of the number of open file descriptors in this process
243 exceeds \fBOPEN_MAX.\fR
247 .ne 2
249 \fB\fBENAMETOOLONG\fR \fR
251 .RS 17n
252 The length of the \fIname\fR string exceeds \fBPATH_MAX,\fR or a pathname
253 component is longer than \fINAME_MAX\fR while \fB_POSIX_NO_TRUNC\fR is in
254 effect.
258 .ne 2
260 \fB\fBENFILE\fR \fR
262 .RS 17n
263 Too many message queues are currently open in the system.
267 .ne 2
269 \fB\fBENOENT\fR \fR
271 .RS 17n
272 \fBO_CREAT\fR is not set and the named message queue does not exist.
276 .ne 2
278 \fB\fBENOSPC\fR \fR
280 .RS 17n
281 There is insufficient space for the creation of the new message queue.
285 .ne 2
287 \fB\fBENOSYS\fR \fR
289 .RS 17n
290 The \fBmq_open()\fR function is not supported by the system.
293 .SH ATTRIBUTES
296 See \fBattributes\fR(5) for descriptions of the following attributes:
301 box;
302 c | c
303 l | l .
304 ATTRIBUTE TYPE  ATTRIBUTE VALUE
306 Interface Stability     Committed
308 MT-Level        MT-Safe
310 Standard        See \fBstandards\fR(5).
313 .SH SEE ALSO
316 \fBexec\fR(2), \fBexit\fR(2), \fBumask\fR(2), \fBsysconf\fR(3C),
317 \fBmqueue.h\fR(3HEAD), \fBmq_close\fR(3C), \fBmq_receive\fR(3C),
318 \fBmq_send\fR(3C), \fBmq_setattr\fR(3C), \fBmq_unlink\fR(3C),
319 \fBattributes\fR(5), \fBstandards\fR(5)
320 .SH NOTES
323 Due to the manner in which message queues are implemented, they should not be
324 considered secure and should not be used in security-sensitive applications.
327 Solaris 2.6 was the first release to support the Asynchronous Input and Output
328 option. Prior to this release, this function always returned \fB\(mi1\fR and
329 set \fBerrno\fR to \fBENOSYS\fR.