]>
Commit | Line | Data |
---|---|---|
80a99f39 MK |
1 | '\" t |
2 | .\" Hey Emacs! This file is -*- nroff -*- source. | |
3 | .\" | |
c11b1abf | 4 | .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com> |
80a99f39 MK |
5 | .\" |
6 | .\" Permission is granted to make and distribute verbatim copies of this | |
7 | .\" manual provided the copyright notice and this permission notice are | |
8 | .\" preserved on all copies. | |
9 | .\" | |
10 | .\" Permission is granted to copy and distribute modified versions of this | |
11 | .\" manual under the conditions for verbatim copying, provided that the | |
12 | .\" entire resulting derived work is distributed under the terms of a | |
13 | .\" permission notice identical to this one. | |
c13182ef | 14 | .\" |
80a99f39 MK |
15 | .\" Since the Linux kernel and libraries are constantly changing, this |
16 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
17 | .\" responsibility for errors or omissions, or for damages resulting from | |
10d76543 MK |
18 | .\" the use of the information contained herein. The author(s) may not |
19 | .\" have taken the same level of care in the production of this manual, | |
20 | .\" which is licensed free of charge, as they might when working | |
21 | .\" professionally. | |
c13182ef | 22 | .\" |
80a99f39 MK |
23 | .\" Formatted or processed versions of this manual, if unaccompanied by |
24 | .\" the source, must acknowledge the copyright and authors of this work. | |
25 | .\" | |
50831f9b | 26 | .TH MQ_SEND 3 2010-09-20 "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 , |
b9f02710 | 34 | .BI " size_t " msg_len ", unsigned " 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 , |
b9f02710 MK |
40 | .BI " size_t " msg_len ", unsigned " msg_prio , |
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. | |
161 | .SH CONFORMING TO | |
162 | POSIX.1-2001. | |
5496c8c1 MK |
163 | .SH NOTES |
164 | On Linux, | |
165 | .BR mq_timedsend () | |
166 | is a system call, and | |
167 | .BR mq_send () | |
168 | is a library function layered on top of that system call. | |
47297adb | 169 | .SH SEE ALSO |
80a99f39 MK |
170 | .BR mq_close (3), |
171 | .BR mq_getattr (3), | |
172 | .BR mq_notify (3), | |
173 | .BR mq_open (3), | |
174 | .BR mq_receive (3), | |
175 | .BR mq_unlink (3), | |
1d7c4d16 MK |
176 | .BR mq_overview (7), |
177 | .BR time (7) |