]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man/man3/mq_send.3
man/, share/mk/: Move man*/ to man/
[thirdparty/man-pages.git] / man / man3 / mq_send.3
CommitLineData
a1eaacb1 1'\" t
c11b1abf 2.\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
80a99f39 3.\"
5fbde956 4.\" SPDX-License-Identifier: Linux-man-pages-copyleft
80a99f39 5.\"
4c1c5274 6.TH mq_send 3 (date) "Linux man-pages (unreleased)"
80a99f39
MK
7.SH NAME
8mq_send, mq_timedsend \- send a message to a message queue
f7477c15
AC
9.SH LIBRARY
10Real-time library
8fc3b2cf 11.RI ( librt ", " \-lrt )
80a99f39
MK
12.SH SYNOPSIS
13.nf
14.B #include <mqueue.h>
c6d039a3 15.P
1eed67e7 16.BI "int mq_send(mqd_t " mqdes ", const char " msg_ptr [. msg_len ],
c1234a3b 17.BI " size_t " msg_len ", unsigned int " msg_prio );
c6d039a3 18.P
80a99f39
MK
19.B #include <time.h>
20.B #include <mqueue.h>
c6d039a3 21.P
1eed67e7 22.BI "int mq_timedsend(mqd_t " mqdes ", const char " msg_ptr [. msg_len ],
c1234a3b 23.BI " size_t " msg_len ", unsigned int " msg_prio ,
b9f02710 24.BI " const struct timespec *" abs_timeout );
80a99f39 25.fi
c6d039a3 26.P
9a30939e 27.ad l
d39ad78f 28.RS -4
9a30939e
MK
29Feature Test Macro Requirements for glibc (see
30.BR feature_test_macros (7)):
d39ad78f 31.RE
c6d039a3 32.P
9a30939e 33.BR mq_timedsend ():
9d2adbae 34.nf
5c10d2c5 35 _POSIX_C_SOURCE >= 200112L
9d2adbae 36.fi
80a99f39
MK
37.SH DESCRIPTION
38.BR mq_send ()
39adds the message pointed to by
0daa9e92 40.I msg_ptr
d9cb0d7d 41to the message queue referred to by the message queue descriptor
80a99f39 42.IR mqdes .
c13182ef 43The
80a99f39
MK
44.I msg_len
45argument specifies the length of the message pointed to by
46.IR msg_ptr ;
47this length must be less than or equal to the queue's
48.I mq_msgsize
49attribute.
50Zero-length messages are allowed.
c6d039a3 51.P
c13182ef 52The
80a99f39 53.I msg_prio
2fda57bd 54argument is a nonnegative integer that specifies the priority
80a99f39 55of this message.
c13182ef
MK
56Messages are placed on the queue in decreasing order of priority,
57with newer messages of the same priority being placed after
80a99f39 58older messages with the same priority.
c1b9bce2
MK
59See
60.BR mq_overview (7)
61for details on the range for the message priority.
c6d039a3 62.P
c13182ef 63If the message queue is already full
80a99f39
MK
64(i.e., the number of messages on the queue equals the queue's
65.I mq_maxmsg
66attribute), then, by default,
67.BR mq_send ()
c13182ef 68blocks until sufficient space becomes available to allow the message
80a99f39 69to be queued, or until the call is interrupted by a signal handler.
c13182ef 70If the
80a99f39
MK
71.B O_NONBLOCK
72flag is enabled for the message queue description,
73then the call instead fails immediately with the error
74.BR EAGAIN .
c6d039a3 75.P
80a99f39
MK
76.BR mq_timedsend ()
77behaves just like
78.BR mq_send (),
79except that if the queue is full and the
80.B O_NONBLOCK
81flag is not enabled for the message queue description, then
82.I abs_timeout
3824cf5b
MK
83points to a structure which specifies how long the call will block.
84This value is an absolute timeout in seconds and nanoseconds
85since the Epoch, 1970-01-01 00:00:00 +0000 (UTC),
e97e048a 86specified in a
87.BR timespec (3)
88structure.
c6d039a3 89.P
80a99f39
MK
90If the message queue is full,
91and the timeout has already expired by the time of the call,
92.BR mq_timedsend ()
93returns immediately.
94.SH RETURN VALUE
95On success,
96.BR mq_send ()
97and
98.BR mq_timedsend ()
99return zero; on error, \-1 is returned, with
c13182ef 100.I errno
80a99f39
MK
101set to indicate the error.
102.SH ERRORS
103.TP
104.B EAGAIN
78ca89ac 105The queue was full, and the
80a99f39
MK
106.B O_NONBLOCK
107flag was set for the message queue description referred to by
108.IR mqdes .
109.TP
110.B EBADF
e186d0ca 111The descriptor specified in
80a99f39 112.I mqdes
e1ca8255 113was invalid or not opened for writing.
80a99f39 114.TP
80a99f39 115.B EINTR
01538d0d
MK
116The call was interrupted by a signal handler; see
117.BR signal (7).
80a99f39
MK
118.TP
119.B EINVAL
c13182ef 120The call would have blocked, and
80a99f39
MK
121.I abs_timeout
122was invalid, either because
123.I tv_sec
124was less than zero, or because
c13182ef 125.I tv_nsec
80a99f39
MK
126was less than zero or greater than 1000 million.
127.TP
eab64696 128.B EMSGSIZE
0daa9e92 129.I msg_len
eab64696
MK
130was greater than the
131.I mq_msgsize
132attribute of the message queue.
133.TP
80a99f39
MK
134.B ETIMEDOUT
135The call timed out before a message could be transferred.
dfc41d9c 136.SH ATTRIBUTES
7ec57137
PH
137For an explanation of the terms used in this section, see
138.BR attributes (7).
139.TS
140allbox;
c466875e 141lbx lb lb
7ec57137
PH
142l l l.
143Interface Attribute Value
144T{
9e54434e
BR
145.na
146.nh
7ec57137 147.BR mq_send (),
dfc41d9c 148.BR mq_timedsend ()
7ec57137
PH
149T} Thread safety MT-Safe
150.TE
4131356c 151.SH VERSIONS
5496c8c1
MK
152On Linux,
153.BR mq_timedsend ()
154is a system call, and
155.BR mq_send ()
156is a library function layered on top of that system call.
4131356c
AC
157.SH STANDARDS
158POSIX.1-2008.
159.SH HISTORY
160POSIX.1-2001.
47297adb 161.SH SEE ALSO
80a99f39
MK
162.BR mq_close (3),
163.BR mq_getattr (3),
164.BR mq_notify (3),
165.BR mq_open (3),
166.BR mq_receive (3),
167.BR mq_unlink (3),
e97e048a 168.BR timespec (3),
1d7c4d16
MK
169.BR mq_overview (7),
170.BR time (7)