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