]>
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. | |
c13182ef | 14 | .\" |
80a99f39 MK |
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 | |
c13182ef MK |
18 | .\" the use of the information contained herein. |
19 | .\" | |
80a99f39 MK |
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 ); | |
c13182ef | 31 | .BI "mqd_t mq_open(const char *" name ", int " oflag ", mode_t " mode , |
911db49e | 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 . | |
c13182ef MK |
39 | For details of the construction of |
40 | .IR name , | |
80a99f39 MK |
41 | see |
42 | .BR mq_overview (7). | |
43 | ||
44 | The | |
45 | .I oflag | |
46 | argument specifies flags that control the operation of the call. | |
c13182ef | 47 | Exactly one of the following must be specified in |
80a99f39 MK |
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 | |
c13182ef MK |
76 | user ID of the calling process. |
77 | The group ownership (group ID) is set to the effective group ID | |
80a99f39 MK |
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 | |
c13182ef | 91 | If |
80a99f39 | 92 | .B O_CREAT |
c13182ef | 93 | is specified in |
80a99f39 MK |
94 | .IR oflag , |
95 | then two additional arguments must be supplied. | |
96 | The | |
97 | .I mode | |
c13182ef | 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. | |
c13182ef | 102 | The |
80a99f39 | 103 | .I attr |
c13182ef MK |
104 | argument specifies attributes for the queue. |
105 | See | |
80a99f39 | 106 | .BR mq_getattr (2) |
c13182ef | 107 | for details. |
80a99f39 MK |
108 | If |
109 | .I attr | |
c13182ef | 110 | is NULL, then the queue is created with implementation-defined |
80a99f39 MK |
111 | default attributes. |
112 | .SH RETURN VALUE | |
113 | On success, | |
114 | .BR mq_open () | |
c13182ef | 115 | returns a message queue descriptor for use by other |
80a99f39 | 116 | message queue functions. |
c13182ef | 117 | On error, |
80a99f39 | 118 | .BR mq_open () |
c13182ef | 119 | returns |
80a99f39 MK |
120 | .IR "(mqd_t)\ \-1", |
121 | with | |
122 | .I errno | |
123 | set to indicate the error. | |
124 | .SH ERRORS | |
125 | .TP | |
c3efd1ac | 126 | .B EACCES |
c13182ef | 127 | The queue exists, but the caller does not have permission to |
80a99f39 MK |
128 | open it in the specified mode. |
129 | .TP | |
130 | .B EINVAL | |
131 | .B O_CREAT | |
c13182ef MK |
132 | was specified in |
133 | .IR oflag , | |
134 | and | |
80a99f39 MK |
135 | .I attr |
136 | was not NULL, but | |
137 | .I attr->mq_maxmsg | |
138 | or | |
139 | .I attr->mq_msqsize | |
140 | was invalid. | |
141 | Both of these fields must be greater than zero. | |
142 | In a process that is unprivileged (does not have the | |
143 | .B CAP_SYS_RESOURCE | |
144 | capability), | |
145 | .I attr->mq_maxmsg | |
146 | must be less than or equal to the | |
147 | .I msg_max | |
148 | limit, and | |
149 | .I attr->mq_msgsize | |
150 | must be less than or equal to the | |
151 | .I msgsize_max | |
c13182ef | 152 | limit. |
80a99f39 MK |
153 | In addition, even in a privileged process, |
154 | .I attr->mq_maxmsg | |
155 | cannot exceed the | |
156 | .B HARD_MAX | |
157 | limit. | |
158 | (See | |
c13182ef | 159 | .BR mq_overview (7) |
80a99f39 MK |
160 | for details of these limits.) |
161 | .TP | |
162 | .B EEXIST | |
163 | Both | |
164 | .B O_CREAT | |
165 | and | |
166 | .B O_EXCL | |
c13182ef | 167 | were specified in |
80a99f39 | 168 | .IR oflag , |
c13182ef | 169 | but a queue with this |
80a99f39 MK |
170 | .I name |
171 | already exists. | |
172 | .TP | |
173 | .B EMFILE | |
c13182ef | 174 | The process already has the maximum number of files and |
80a99f39 MK |
175 | message queues open. |
176 | .TP | |
177 | .B ENAMETOOLONG | |
178 | .IR name | |
179 | was too long. | |
180 | .TP | |
181 | .B ENFILE | |
c13182ef | 182 | The system limit on the total number of open files and message queues |
80a99f39 MK |
183 | has been reached. |
184 | .TP | |
185 | .B ENOENT | |
186 | The | |
187 | .B O_CREAT | |
c13182ef | 188 | flag was not specified in |
80a99f39 | 189 | .IR oflag , |
c13182ef | 190 | and no queue with this |
80a99f39 MK |
191 | .I name |
192 | exists. | |
193 | .TP | |
194 | .B ENOMEM | |
195 | Insufficient memory. | |
196 | .TP | |
197 | .B ENOSPC | |
198 | Insufficient space for the creation of a new message queue. | |
199 | This probably occurred because the | |
200 | .I queues_max | |
201 | limit was encountered; see | |
202 | .BR mq_overview (7). | |
203 | .SH CONFORMING TO | |
204 | POSIX.1-2001. | |
205 | .SH BUGS | |
c13182ef MK |
206 | In kernels before 2.6.14, |
207 | the process umask was not applied to the permissions specified in | |
80a99f39 MK |
208 | .IR mode . |
209 | .SH "SEE ALSO" | |
210 | .BR mq_close (3), | |
211 | .BR mq_getattr (3), | |
212 | .BR mq_notify (3), | |
213 | .BR mq_receive (3), | |
214 | .BR mq_send (3), | |
215 | .BR mq_unlink (3), | |
216 | .BR mq_overview (7) |