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