]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mq_send.3
getauxval.3: wfix
[thirdparty/man-pages.git] / man3 / mq_send.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.\"
460495ca 26.TH MQ_SEND 3 2015-08-08 "Linux" "Linux Programmer's Manual"
80a99f39
MK
27.SH NAME
28mq_send, mq_timedsend \- send a message to a message queue
29.SH SYNOPSIS
30.nf
31.B #include <mqueue.h>
32.sp
c9e83f06 33.BI "int mq_send(mqd_t " mqdes ", const char *" msg_ptr ,
c1234a3b 34.BI " size_t " msg_len ", unsigned int " msg_prio );
80a99f39 35.sp
80a99f39
MK
36.B #include <time.h>
37.B #include <mqueue.h>
38.sp
c9e83f06 39.BI "int mq_timedsend(mqd_t " mqdes ", const char *" msg_ptr ,
c1234a3b 40.BI " size_t " msg_len ", unsigned int " msg_prio ,
b9f02710 41.BI " const struct timespec *" abs_timeout );
80a99f39 42.fi
1b2d3fca
MK
43.sp
44Link with \fI\-lrt\fP.
9a30939e
MK
45.sp
46.ad l
47.in -4n
48Feature Test Macro Requirements for glibc (see
49.BR feature_test_macros (7)):
50.in
51.sp
52.BR mq_timedsend ():
53.RS 4
54_XOPEN_SOURCE\ >=\ 600 || _POSIX_C_SOURCE\ >=\ 200112L
55.RE
56.ad
80a99f39
MK
57.SH DESCRIPTION
58.BR mq_send ()
59adds the message pointed to by
0daa9e92 60.I msg_ptr
80a99f39
MK
61to the message queue referred to by the descriptor
62.IR mqdes .
c13182ef 63The
80a99f39
MK
64.I msg_len
65argument specifies the length of the message pointed to by
66.IR msg_ptr ;
67this length must be less than or equal to the queue's
68.I mq_msgsize
69attribute.
70Zero-length messages are allowed.
71
c13182ef 72The
80a99f39 73.I msg_prio
2fda57bd 74argument is a nonnegative integer that specifies the priority
80a99f39 75of this message.
c13182ef
MK
76Messages are placed on the queue in decreasing order of priority,
77with newer messages of the same priority being placed after
80a99f39
MK
78older messages with the same priority.
79
c13182ef 80If the message queue is already full
80a99f39
MK
81(i.e., the number of messages on the queue equals the queue's
82.I mq_maxmsg
83attribute), then, by default,
84.BR mq_send ()
c13182ef 85blocks until sufficient space becomes available to allow the message
80a99f39 86to be queued, or until the call is interrupted by a signal handler.
c13182ef 87If the
80a99f39
MK
88.B O_NONBLOCK
89flag is enabled for the message queue description,
90then the call instead fails immediately with the error
91.BR EAGAIN .
92
93.BR mq_timedsend ()
94behaves just like
95.BR mq_send (),
96except that if the queue is full and the
97.B O_NONBLOCK
98flag is not enabled for the message queue description, then
99.I abs_timeout
3824cf5b
MK
100points to a structure which specifies how long the call will block.
101This value is an absolute timeout in seconds and nanoseconds
102since the Epoch, 1970-01-01 00:00:00 +0000 (UTC),
80a99f39
MK
103specified in the following structure:
104.sp
bd191423 105.in +4n
80a99f39
MK
106.nf
107struct timespec {
108 time_t tv_sec; /* seconds */
109 long tv_nsec; /* nanoseconds */
110};
111
112.fi
bd191423 113.in
80a99f39
MK
114If the message queue is full,
115and the timeout has already expired by the time of the call,
116.BR mq_timedsend ()
117returns immediately.
118.SH RETURN VALUE
119On success,
120.BR mq_send ()
121and
122.BR mq_timedsend ()
123return zero; on error, \-1 is returned, with
c13182ef 124.I errno
80a99f39
MK
125set to indicate the error.
126.SH ERRORS
127.TP
128.B EAGAIN
78ca89ac 129The queue was full, and the
80a99f39
MK
130.B O_NONBLOCK
131flag was set for the message queue description referred to by
132.IR mqdes .
133.TP
134.B EBADF
c13182ef 135The descriptor specified in
80a99f39
MK
136.I mqdes
137was invalid.
138.TP
80a99f39 139.B EINTR
01538d0d
MK
140The call was interrupted by a signal handler; see
141.BR signal (7).
80a99f39
MK
142.TP
143.B EINVAL
c13182ef 144The call would have blocked, and
80a99f39
MK
145.I abs_timeout
146was invalid, either because
147.I tv_sec
148was less than zero, or because
c13182ef 149.I tv_nsec
80a99f39
MK
150was less than zero or greater than 1000 million.
151.TP
eab64696 152.B EMSGSIZE
0daa9e92 153.I msg_len
eab64696
MK
154was greater than the
155.I mq_msgsize
156attribute of the message queue.
157.TP
80a99f39
MK
158.B ETIMEDOUT
159The call timed out before a message could be transferred.
dfc41d9c 160.SH ATTRIBUTES
7ec57137
PH
161For an explanation of the terms used in this section, see
162.BR attributes (7).
163.TS
164allbox;
165lbw25 lb lb
166l l l.
167Interface Attribute Value
168T{
169.BR mq_send (),
dfc41d9c 170.BR mq_timedsend ()
7ec57137
PH
171T} Thread safety MT-Safe
172.TE
80a99f39 173.SH CONFORMING TO
fcabb4b1 174POSIX.1-2001, POSIX.1-2008.
5496c8c1
MK
175.SH NOTES
176On Linux,
177.BR mq_timedsend ()
178is a system call, and
179.BR mq_send ()
180is a library function layered on top of that system call.
47297adb 181.SH SEE ALSO
80a99f39
MK
182.BR mq_close (3),
183.BR mq_getattr (3),
184.BR mq_notify (3),
185.BR mq_open (3),
186.BR mq_receive (3),
187.BR mq_unlink (3),
1d7c4d16
MK
188.BR mq_overview (7),
189.BR time (7)