]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mq_open.3
Replaced tabs with spaces
[thirdparty/man-pages.git] / man3 / mq_open.3
CommitLineData
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
25mq_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 ()
36creates a new POSIX message queue or opens an existing queue.
37The queue is identified by
38.IR name .
39For details of the construction of
40.IR name ,
41see
42.BR mq_overview (7).
43
44The
45.I oflag
46argument specifies flags that control the operation of the call.
47Exactly one of the following must be specified in
48.IR oflag:
49.TP
50.B O_RDONLY
51Open the queue to receive messages only.
52.TP
53.B O_WRONLY
54Open the queue to send messages only.
55.TP
56.B O_RDWR
57Open the queue to both send and receive messages.
58.PP
59Zero or more of the following flags can additionally be
60.IR OR ed
61in
62.IR oflag :
63.TP
64.B O_NONBLOCK
65Open the queue in non-blocking mode.
66In circumstances where
67.BR mq_receive ()
68and
69.BR mq_send ()
70would normally block, these functions instead fail with the error
71.BR EAGAIN .
72.TP
73.B O_CREAT
74Create the message queue if it does not exist.
75The owner (user ID) of the message queue is set to the effective
76user ID of the calling process.
77The group ownership (group ID) is set to the effective group ID
78of the calling process.
79.\" In reality the file system IDs are used on Linux.
80.TP
81.B O_EXCL
82If
83.B O_CREAT
84was specified in
85.IR oflag ,
86and a queue with the given
87.I name
88already exists, then fail with the error
89.BR EEXIST .
90.PP
91If
92.B O_CREAT
93is specified in
94.IR oflag ,
95then two additional arguments must be supplied.
96The
97.I mode
98argument specifies the permissions to be placed on the new queue,
7295b7ed 99as for
80a99f39
MK
100.BR open (2).
101The permissions settings are masked against the process umask.
102The
103.I attr
104argument specifies attributes for the queue. See
105.BR mq_getattr (2)
106for details.
107If
108.I attr
109is NULL, then the queue is created with implementation-defined
110default attributes.
111.SH RETURN VALUE
112On success,
113.BR mq_open ()
114returns a message queue descriptor for use by other
115message queue functions.
116On error,
117.BR mq_open ()
118returns
119.IR "(mqd_t)\ \-1",
120with
121.I errno
122set to indicate the error.
123.SH ERRORS
124.TP
c3efd1ac 125.B EACCES
80a99f39
MK
126The queue exists, but the caller does not have permission to
127open it in the specified mode.
128.TP
129.B EINVAL
130.B O_CREAT
131was specified in
132.IR oflag ,
133and
134.I attr
135was not NULL, but
136.I attr->mq_maxmsg
137or
138.I attr->mq_msqsize
139was invalid.
140Both of these fields must be greater than zero.
141In a process that is unprivileged (does not have the
142.B CAP_SYS_RESOURCE
143capability),
144.I attr->mq_maxmsg
145must be less than or equal to the
146.I msg_max
147limit, and
148.I attr->mq_msgsize
149must be less than or equal to the
150.I msgsize_max
151limit.
152In addition, even in a privileged process,
153.I attr->mq_maxmsg
154cannot exceed the
155.B HARD_MAX
156limit.
157(See
158.BR mq_overview (7)
159for details of these limits.)
160.TP
161.B EEXIST
162Both
163.B O_CREAT
164and
165.B O_EXCL
166were specified in
167.IR oflag ,
168but a queue with this
169.I name
170already exists.
171.TP
172.B EMFILE
173The process already has the maximum number of files and
174message queues open.
175.TP
176.B ENAMETOOLONG
177.IR name
178was too long.
179.TP
180.B ENFILE
181The system limit on the total number of open files and message queues
182has been reached.
183.TP
184.B ENOENT
185The
186.B O_CREAT
187flag was not specified in
188.IR oflag ,
189and no queue with this
190.I name
191exists.
192.TP
193.B ENOMEM
194Insufficient memory.
195.TP
196.B ENOSPC
197Insufficient space for the creation of a new message queue.
198This probably occurred because the
199.I queues_max
200limit was encountered; see
201.BR mq_overview (7).
202.SH CONFORMING TO
203POSIX.1-2001.
204.SH BUGS
205In kernels before 2.6.14,
206the 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)