]>
Commit | Line | Data |
---|---|---|
80a99f39 MK |
1 | '\" t |
2 | .\" Hey Emacs! This file is -*- nroff -*- source. | |
3 | .\" | |
4 | .\" Copyright (C) 2006 Michael Kerrisk <mtk-manpages@gmx.net> | |
5 | .\" | |
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. | |
9 | .\" | |
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. | |
14 | .\" | |
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. | |
19 | .\" | |
20 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
21 | .\" the source, must acknowledge the copyright and authors of this work. | |
22 | .\" | |
23 | .TH MQ_OPEN 3 2006-02-25 "Linux 2.6.16" "Linux Programmer's Manual" | |
24 | .SH NAME | |
25 | mq_open \- open a message queue | |
26 | .SH SYNOPSIS | |
27 | .nf | |
28 | .B #include <mqueue.h> | |
29 | .sp | |
30 | .BI "mqd_t mq_open(const char *" name ", int " oflag ); | |
911db49e MK |
31 | .BI "mqd_t mq_open(const char *" name ", int " oflag ", mode_t " mode , |
32 | .BI " struct mq_attr *" attr ); | |
80a99f39 MK |
33 | .fi |
34 | .SH DESCRIPTION | |
35 | .BR mq_open () | |
36 | creates a new POSIX message queue or opens an existing queue. | |
37 | The queue is identified by | |
38 | .IR name . | |
39 | For details of the construction of | |
40 | .IR name , | |
41 | see | |
42 | .BR mq_overview (7). | |
43 | ||
44 | The | |
45 | .I oflag | |
46 | argument specifies flags that control the operation of the call. | |
47 | Exactly one of the following must be specified in | |
48 | .IR oflag: | |
49 | .TP | |
50 | .B O_RDONLY | |
51 | Open the queue to receive messages only. | |
52 | .TP | |
53 | .B O_WRONLY | |
54 | Open the queue to send messages only. | |
55 | .TP | |
56 | .B O_RDWR | |
57 | Open the queue to both send and receive messages. | |
58 | .PP | |
59 | Zero or more of the following flags can additionally be | |
60 | .IR OR ed | |
61 | in | |
62 | .IR oflag : | |
63 | .TP | |
64 | .B O_NONBLOCK | |
65 | Open the queue in non-blocking mode. | |
66 | In circumstances where | |
67 | .BR mq_receive () | |
68 | and | |
69 | .BR mq_send () | |
70 | would normally block, these functions instead fail with the error | |
71 | .BR EAGAIN . | |
72 | .TP | |
73 | .B O_CREAT | |
74 | Create the message queue if it does not exist. | |
75 | The owner (user ID) of the message queue is set to the effective | |
76 | user ID of the calling process. | |
77 | The group ownership (group ID) is set to the effective group ID | |
78 | of the calling process. | |
79 | .\" In reality the file system IDs are used on Linux. | |
80 | .TP | |
81 | .B O_EXCL | |
82 | If | |
83 | .B O_CREAT | |
84 | was specified in | |
85 | .IR oflag , | |
86 | and a queue with the given | |
87 | .I name | |
88 | already exists, then fail with the error | |
89 | .BR EEXIST . | |
90 | .PP | |
91 | If | |
92 | .B O_CREAT | |
93 | is specified in | |
94 | .IR oflag , | |
95 | then two additional arguments must be supplied. | |
96 | The | |
97 | .I mode | |
98 | argument specifies the permissions to be placed on the new queue, | |
7295b7ed | 99 | as for |
80a99f39 MK |
100 | .BR open (2). |
101 | The permissions settings are masked against the process umask. | |
102 | The | |
103 | .I attr | |
104 | argument specifies attributes for the queue. See | |
105 | .BR mq_getattr (2) | |
106 | for details. | |
107 | If | |
108 | .I attr | |
109 | is NULL, then the queue is created with implementation-defined | |
110 | default attributes. | |
111 | .SH RETURN VALUE | |
112 | On success, | |
113 | .BR mq_open () | |
114 | returns a message queue descriptor for use by other | |
115 | message queue functions. | |
116 | On error, | |
117 | .BR mq_open () | |
118 | returns | |
119 | .IR "(mqd_t)\ \-1", | |
120 | with | |
121 | .I errno | |
122 | set to indicate the error. | |
123 | .SH ERRORS | |
124 | .TP | |
c3efd1ac | 125 | .B EACCES |
80a99f39 MK |
126 | The queue exists, but the caller does not have permission to |
127 | open it in the specified mode. | |
128 | .TP | |
129 | .B EINVAL | |
130 | .B O_CREAT | |
131 | was specified in | |
132 | .IR oflag , | |
133 | and | |
134 | .I attr | |
135 | was not NULL, but | |
136 | .I attr->mq_maxmsg | |
137 | or | |
138 | .I attr->mq_msqsize | |
139 | was invalid. | |
140 | Both of these fields must be greater than zero. | |
141 | In a process that is unprivileged (does not have the | |
142 | .B CAP_SYS_RESOURCE | |
143 | capability), | |
144 | .I attr->mq_maxmsg | |
145 | must be less than or equal to the | |
146 | .I msg_max | |
147 | limit, and | |
148 | .I attr->mq_msgsize | |
149 | must be less than or equal to the | |
150 | .I msgsize_max | |
151 | limit. | |
152 | In addition, even in a privileged process, | |
153 | .I attr->mq_maxmsg | |
154 | cannot exceed the | |
155 | .B HARD_MAX | |
156 | limit. | |
157 | (See | |
158 | .BR mq_overview (7) | |
159 | for details of these limits.) | |
160 | .TP | |
161 | .B EEXIST | |
162 | Both | |
163 | .B O_CREAT | |
164 | and | |
165 | .B O_EXCL | |
166 | were specified in | |
167 | .IR oflag , | |
168 | but a queue with this | |
169 | .I name | |
170 | already exists. | |
171 | .TP | |
172 | .B EMFILE | |
173 | The process already has the maximum number of files and | |
174 | message queues open. | |
175 | .TP | |
176 | .B ENAMETOOLONG | |
177 | .IR name | |
178 | was too long. | |
179 | .TP | |
180 | .B ENFILE | |
181 | The system limit on the total number of open files and message queues | |
182 | has been reached. | |
183 | .TP | |
184 | .B ENOENT | |
185 | The | |
186 | .B O_CREAT | |
187 | flag was not specified in | |
188 | .IR oflag , | |
189 | and no queue with this | |
190 | .I name | |
191 | exists. | |
192 | .TP | |
193 | .B ENOMEM | |
194 | Insufficient memory. | |
195 | .TP | |
196 | .B ENOSPC | |
197 | Insufficient space for the creation of a new message queue. | |
198 | This probably occurred because the | |
199 | .I queues_max | |
200 | limit was encountered; see | |
201 | .BR mq_overview (7). | |
202 | .SH CONFORMING TO | |
203 | POSIX.1-2001. | |
204 | .SH BUGS | |
205 | In kernels before 2.6.14, | |
206 | the process umask was not applied to the permissions specified in | |
207 | .IR mode . | |
208 | .SH "SEE ALSO" | |
209 | .BR mq_close (3), | |
210 | .BR mq_getattr (3), | |
211 | .BR mq_notify (3), | |
212 | .BR mq_receive (3), | |
213 | .BR mq_send (3), | |
214 | .BR mq_unlink (3), | |
215 | .BR mq_overview (7) |