]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mq_getattr.3
intro.1, _exit.2, access.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bind.2, chdir...
[thirdparty/man-pages.git] / man3 / mq_getattr.3
CommitLineData
80a99f39 1'\" t
c11b1abf 2.\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
80a99f39 3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
80a99f39
MK
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
c13182ef 13.\"
80a99f39
MK
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
10d76543
MK
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
c13182ef 21.\"
80a99f39
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 24.\" %%%LICENSE_END
80a99f39 25.\"
c9e83f06 26.TH MQ_GETATTR 3 2010-08-29 "Linux" "Linux Programmer's Manual"
80a99f39
MK
27.SH NAME
28mq_getattr, mq_setattr \- get/set message queue attributes
29.SH SYNOPSIS
30.nf
31.B #include <mqueue.h>
32.sp
c9e83f06 33.BI "int mq_getattr(mqd_t " mqdes ", struct mq_attr *" attr );
5895e7eb 34
c9e83f06 35.BI "int mq_setattr(mqd_t " mqdes ", struct mq_attr *" newattr ","
80a99f39
MK
36.BI " struct mq_attr *" oldattr );
37.fi
1b2d3fca
MK
38.sp
39Link with \fI\-lrt\fP.
80a99f39
MK
40.SH DESCRIPTION
41.BR mq_getattr ()
42and
43.BR mq_setattr ()
c13182ef 44respectively retrieve and modify attributes of the message queue
80a99f39
MK
45referred to by the descriptor
46.IR mqdes .
47
48.BR mq_getattr ()
49returns an
50.I mq_attr
c13182ef 51structure in the buffer pointed by
28cdb68a 52.IR attr .
80a99f39 53This structure is defined as:
a08ea57c 54.in +4n
80a99f39
MK
55.nf
56
57struct mq_attr {
58 long mq_flags; /* Flags: 0 or O_NONBLOCK */
59 long mq_maxmsg; /* Max. # of messages on queue */
60 long mq_msgsize; /* Max. message size (bytes) */
61 long mq_curmsgs; /* # of messages currently in queue */
62};
63.fi
a08ea57c 64.in
80a99f39
MK
65.PP
66The
67.I mq_flags
68field contains flags associated with the open message queue description.
d9bfdb9c 69This field is initialized when the queue is created by
fb186734 70.BR mq_open (3).
80a99f39
MK
71The only flag that can appear in this field is
72.BR O_NONBLOCK .
73
c13182ef 74The
80a99f39
MK
75.I mq_maxmsg
76and
77.I mq_msgsize
78fields are set when the message queue is created by
fb186734 79.BR mq_open (3).
80a99f39
MK
80The
81.I mq_maxmsg
c13182ef 82field is an upper limit on the number of messages
80a99f39 83that may be placed on the queue using
fb186734 84.BR mq_send (3).
80a99f39
MK
85The
86.I mq_msgsize
87field is an upper limit on the size of messages
88that may be placed on the queue.
89Both of these fields must have a value greater than zero.
c13182ef
MK
90Two
91.I /proc
92files that place ceilings on the values for these fields are described in
80a99f39
MK
93.BR mq_open (3).
94
c13182ef 95The
80a99f39
MK
96.I mq_curmsgs
97field returns the number of messages currently held in the queue.
98
99.BR mq_setattr ()
c13182ef 100sets message queue attributes using information supplied in the
80a99f39
MK
101.I mq_attr
102structure pointed to by
103.IR newattr .
104The only attribute that can be modified is the setting of the
105.B O_NONBLOCK
106flag in
107.IR mq_flags .
108The other fields in
109.I newattr
110are ignored.
111If the
112.I oldattr
113field is not NULL,
114then the buffer that it points to is used to return an
115.I mq_attr
116structure that contains the same information that is returned by
117.BR mq_getattr ().
118.SH RETURN VALUE
119On success
120.BR mq_getattr ()
121and
122.BR mq_setattr ()
123return 0; on error, \-1 is returned, with
c13182ef 124.I errno
80a99f39
MK
125set to indicate the error.
126.SH ERRORS
127.TP
128.B EBADF
c13182ef 129The descriptor specified in
80a99f39
MK
130.I mqdes
131is invalid.
132.TP
133.B EINVAL
94e9d9fe 134.I newattr\->mq_flags
80a99f39
MK
135contained set bits other than
136.BR O_NONBLOCK .
137.SH CONFORMING TO
138POSIX.1-2001.
247ac1d3
MK
139.SH NOTES
140On Linux,
141.BR mq_getattr ()
142and
143.BR mq_setattr ()
144are library functions layered on top of the
145.BR mq_getsetattr (2)
146system call.
47297adb 147.SH SEE ALSO
80a99f39
MK
148.BR mq_close (3),
149.BR mq_notify (3),
150.BR mq_open (3),
151.BR mq_receive (3),
152.BR mq_send (3),
153.BR mq_unlink (3),
154.BR mq_overview (7)