]>
Commit | Line | Data |
---|---|---|
80a99f39 MK |
1 | '\" t |
2 | .\" Hey Emacs! This file is -*- nroff -*- source. | |
3 | .\" | |
4 | .\" Copyright (C) 2006 Michael Kerrisk <mtk-manpages@gmx.net> | |
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 | |
c13182ef MK |
18 | .\" the use of the information contained herein. |
19 | .\" | |
80a99f39 MK |
20 | .\" Formatted or processed versions of this manual, if unaccompanied by |
21 | .\" the source, must acknowledge the copyright and authors of this work. | |
22 | .\" | |
d9343c5c | 23 | .TH MQ_SEND 3 2006-02-25 "Linux" "Linux Programmer's Manual" |
80a99f39 MK |
24 | .SH NAME |
25 | mq_send, mq_timedsend \- send a message to a message queue | |
26 | .SH SYNOPSIS | |
27 | .nf | |
28 | .B #include <mqueue.h> | |
29 | .sp | |
30 | .BI "mqd_t mq_send(mqd_t " mqdes ", const char *" msg_ptr , | |
b9f02710 | 31 | .BI " size_t " msg_len ", unsigned " msg_prio ); |
80a99f39 MK |
32 | .sp |
33 | .B #define _XOPEN_SOURCE 600 | |
34 | .B #include <time.h> | |
35 | .B #include <mqueue.h> | |
36 | .sp | |
37 | .BI "mqd_t mq_timedsend(mqd_t " mqdes ", const char *" msg_ptr , | |
b9f02710 MK |
38 | .BI " size_t " msg_len ", unsigned " msg_prio , |
39 | .BI " const struct timespec *" abs_timeout ); | |
80a99f39 MK |
40 | .fi |
41 | .SH DESCRIPTION | |
42 | .BR mq_send () | |
43 | adds the message pointed to by | |
44 | .IR msg_ptr | |
45 | to the message queue referred to by the descriptor | |
46 | .IR mqdes . | |
c13182ef | 47 | The |
80a99f39 MK |
48 | .I msg_len |
49 | argument specifies the length of the message pointed to by | |
50 | .IR msg_ptr ; | |
51 | this length must be less than or equal to the queue's | |
52 | .I mq_msgsize | |
53 | attribute. | |
54 | Zero-length messages are allowed. | |
55 | ||
c13182ef | 56 | The |
80a99f39 | 57 | .I msg_prio |
c13182ef | 58 | argument is a non-negative integer that specifies the priority |
80a99f39 | 59 | of this message. |
c13182ef MK |
60 | Messages are placed on the queue in decreasing order of priority, |
61 | with newer messages of the same priority being placed after | |
80a99f39 MK |
62 | older messages with the same priority. |
63 | ||
c13182ef | 64 | If the message queue is already full |
80a99f39 MK |
65 | (i.e., the number of messages on the queue equals the queue's |
66 | .I mq_maxmsg | |
67 | attribute), then, by default, | |
68 | .BR mq_send () | |
c13182ef | 69 | blocks until sufficient space becomes available to allow the message |
80a99f39 | 70 | to be queued, or until the call is interrupted by a signal handler. |
c13182ef | 71 | If the |
80a99f39 MK |
72 | .B O_NONBLOCK |
73 | flag is enabled for the message queue description, | |
74 | then the call instead fails immediately with the error | |
75 | .BR EAGAIN . | |
76 | ||
77 | .BR mq_timedsend () | |
78 | behaves just like | |
79 | .BR mq_send (), | |
80 | except that if the queue is full and the | |
81 | .B O_NONBLOCK | |
82 | flag is not enabled for the message queue description, then | |
83 | .I abs_timeout | |
c13182ef | 84 | points to a structure which specifies a ceiling on the time for which |
80a99f39 MK |
85 | the call will block. |
86 | This ceiling is an absolute timeout in seconds and nanoseconds | |
87 | since the Epoch (midnight on the morning of 1 January 1970), | |
88 | specified in the following structure: | |
89 | .sp | |
90 | .RS | |
91 | .nf | |
92 | struct timespec { | |
93 | time_t tv_sec; /* seconds */ | |
94 | long tv_nsec; /* nanoseconds */ | |
95 | }; | |
96 | ||
97 | .fi | |
98 | .RE | |
99 | If the message queue is full, | |
100 | and the timeout has already expired by the time of the call, | |
101 | .BR mq_timedsend () | |
102 | returns immediately. | |
103 | .SH RETURN VALUE | |
104 | On success, | |
105 | .BR mq_send () | |
106 | and | |
107 | .BR mq_timedsend () | |
108 | return zero; on error, \-1 is returned, with | |
c13182ef | 109 | .I errno |
80a99f39 MK |
110 | set to indicate the error. |
111 | .SH ERRORS | |
112 | .TP | |
113 | .B EAGAIN | |
114 | The queue was empty, and the | |
115 | .B O_NONBLOCK | |
116 | flag was set for the message queue description referred to by | |
117 | .IR mqdes . | |
118 | .TP | |
119 | .B EBADF | |
c13182ef | 120 | The descriptor specified in |
80a99f39 MK |
121 | .I mqdes |
122 | was invalid. | |
123 | .TP | |
124 | .B EMSGSIZE | |
c13182ef MK |
125 | .IR msg_len |
126 | was greater than the | |
80a99f39 MK |
127 | .I mq_msgsize |
128 | attribute of the message queue. | |
129 | .TP | |
130 | .B EINTR | |
131 | The call was interrupted by a signal handler. | |
132 | .TP | |
133 | .B EINVAL | |
c13182ef | 134 | The call would have blocked, and |
80a99f39 MK |
135 | .I abs_timeout |
136 | was invalid, either because | |
137 | .I tv_sec | |
138 | was less than zero, or because | |
c13182ef | 139 | .I tv_nsec |
80a99f39 MK |
140 | was less than zero or greater than 1000 million. |
141 | .TP | |
142 | .B ETIMEDOUT | |
143 | The call timed out before a message could be transferred. | |
144 | .SH CONFORMING TO | |
145 | POSIX.1-2001. | |
146 | .SH "SEE ALSO" | |
147 | .BR mq_close (3), | |
148 | .BR mq_getattr (3), | |
149 | .BR mq_notify (3), | |
150 | .BR mq_open (3), | |
151 | .BR mq_receive (3), | |
152 | .BR mq_unlink (3), | |
0a90178c | 153 | .BR feature_test_macros (7), |
80a99f39 | 154 | .BR mq_overview (7) |