]>
Commit | Line | Data |
---|---|---|
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 |
8 | mq_send, mq_timedsend \- send a message to a message queue | |
f7477c15 AC |
9 | .SH LIBRARY |
10 | Real-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 |
29 | Feature 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 () | |
39 | adds the message pointed to by | |
0daa9e92 | 40 | .I msg_ptr |
d9cb0d7d | 41 | to the message queue referred to by the message queue descriptor |
80a99f39 | 42 | .IR mqdes . |
c13182ef | 43 | The |
80a99f39 MK |
44 | .I msg_len |
45 | argument specifies the length of the message pointed to by | |
46 | .IR msg_ptr ; | |
47 | this length must be less than or equal to the queue's | |
48 | .I mq_msgsize | |
49 | attribute. | |
50 | Zero-length messages are allowed. | |
c6d039a3 | 51 | .P |
c13182ef | 52 | The |
80a99f39 | 53 | .I msg_prio |
2fda57bd | 54 | argument is a nonnegative integer that specifies the priority |
80a99f39 | 55 | of this message. |
c13182ef MK |
56 | Messages are placed on the queue in decreasing order of priority, |
57 | with newer messages of the same priority being placed after | |
80a99f39 | 58 | older messages with the same priority. |
c1b9bce2 MK |
59 | See |
60 | .BR mq_overview (7) | |
61 | for details on the range for the message priority. | |
c6d039a3 | 62 | .P |
c13182ef | 63 | If 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 | |
66 | attribute), then, by default, | |
67 | .BR mq_send () | |
c13182ef | 68 | blocks until sufficient space becomes available to allow the message |
80a99f39 | 69 | to be queued, or until the call is interrupted by a signal handler. |
c13182ef | 70 | If the |
80a99f39 MK |
71 | .B O_NONBLOCK |
72 | flag is enabled for the message queue description, | |
73 | then the call instead fails immediately with the error | |
74 | .BR EAGAIN . | |
c6d039a3 | 75 | .P |
80a99f39 MK |
76 | .BR mq_timedsend () |
77 | behaves just like | |
78 | .BR mq_send (), | |
79 | except that if the queue is full and the | |
80 | .B O_NONBLOCK | |
81 | flag is not enabled for the message queue description, then | |
82 | .I abs_timeout | |
3824cf5b MK |
83 | points to a structure which specifies how long the call will block. |
84 | This value is an absolute timeout in seconds and nanoseconds | |
85 | since the Epoch, 1970-01-01 00:00:00 +0000 (UTC), | |
e97e048a | 86 | specified in a |
87 | .BR timespec (3) | |
88 | structure. | |
c6d039a3 | 89 | .P |
80a99f39 MK |
90 | If the message queue is full, |
91 | and the timeout has already expired by the time of the call, | |
92 | .BR mq_timedsend () | |
93 | returns immediately. | |
94 | .SH RETURN VALUE | |
95 | On success, | |
96 | .BR mq_send () | |
97 | and | |
98 | .BR mq_timedsend () | |
99 | return zero; on error, \-1 is returned, with | |
c13182ef | 100 | .I errno |
80a99f39 MK |
101 | set to indicate the error. |
102 | .SH ERRORS | |
103 | .TP | |
104 | .B EAGAIN | |
78ca89ac | 105 | The queue was full, and the |
80a99f39 MK |
106 | .B O_NONBLOCK |
107 | flag was set for the message queue description referred to by | |
108 | .IR mqdes . | |
109 | .TP | |
110 | .B EBADF | |
e186d0ca | 111 | The descriptor specified in |
80a99f39 | 112 | .I mqdes |
e1ca8255 | 113 | was invalid or not opened for writing. |
80a99f39 | 114 | .TP |
80a99f39 | 115 | .B EINTR |
01538d0d MK |
116 | The call was interrupted by a signal handler; see |
117 | .BR signal (7). | |
80a99f39 MK |
118 | .TP |
119 | .B EINVAL | |
c13182ef | 120 | The call would have blocked, and |
80a99f39 MK |
121 | .I abs_timeout |
122 | was invalid, either because | |
123 | .I tv_sec | |
124 | was less than zero, or because | |
c13182ef | 125 | .I tv_nsec |
80a99f39 MK |
126 | was less than zero or greater than 1000 million. |
127 | .TP | |
eab64696 | 128 | .B EMSGSIZE |
0daa9e92 | 129 | .I msg_len |
eab64696 MK |
130 | was greater than the |
131 | .I mq_msgsize | |
132 | attribute of the message queue. | |
133 | .TP | |
80a99f39 MK |
134 | .B ETIMEDOUT |
135 | The call timed out before a message could be transferred. | |
dfc41d9c | 136 | .SH ATTRIBUTES |
7ec57137 PH |
137 | For an explanation of the terms used in this section, see |
138 | .BR attributes (7). | |
139 | .TS | |
140 | allbox; | |
c466875e | 141 | lbx lb lb |
7ec57137 PH |
142 | l l l. |
143 | Interface Attribute Value | |
144 | T{ | |
9e54434e BR |
145 | .na |
146 | .nh | |
7ec57137 | 147 | .BR mq_send (), |
dfc41d9c | 148 | .BR mq_timedsend () |
7ec57137 PH |
149 | T} Thread safety MT-Safe |
150 | .TE | |
4131356c | 151 | .SH VERSIONS |
5496c8c1 MK |
152 | On Linux, |
153 | .BR mq_timedsend () | |
154 | is a system call, and | |
155 | .BR mq_send () | |
156 | is a library function layered on top of that system call. | |
4131356c AC |
157 | .SH STANDARDS |
158 | POSIX.1-2008. | |
159 | .SH HISTORY | |
160 | POSIX.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) |