1 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .TH MQ_SEND 3 2021-03-22 "Linux" "Linux Programmer's Manual"
27 mq_send, mq_timedsend \- send a message to a message queue
30 .B #include <mqueue.h>
32 .BI "int mq_send(mqd_t " mqdes ", const char *" msg_ptr ,
33 .BI " size_t " msg_len ", unsigned int " msg_prio );
36 .B #include <mqueue.h>
38 .BI "int mq_timedsend(mqd_t " mqdes ", const char *" msg_ptr ,
39 .BI " size_t " msg_len ", unsigned int " msg_prio ,
40 .BI " const struct timespec *" abs_timeout );
43 Link with \fI\-lrt\fP.
47 Feature Test Macro Requirements for glibc (see
48 .BR feature_test_macros (7)):
53 _POSIX_C_SOURCE >= 200112L
57 adds the message pointed to by
59 to the message queue referred to by the message queue descriptor
63 argument specifies the length of the message pointed to by
65 this length must be less than or equal to the queue's
68 Zero-length messages are allowed.
72 argument is a nonnegative integer that specifies the priority
74 Messages are placed on the queue in decreasing order of priority,
75 with newer messages of the same priority being placed after
76 older messages with the same priority.
79 for details on the range for the message priority.
81 If the message queue is already full
82 (i.e., the number of messages on the queue equals the queue's
84 attribute), then, by default,
86 blocks until sufficient space becomes available to allow the message
87 to be queued, or until the call is interrupted by a signal handler.
90 flag is enabled for the message queue description,
91 then the call instead fails immediately with the error
97 except that if the queue is full and the
99 flag is not enabled for the message queue description, then
101 points to a structure which specifies how long the call will block.
102 This value is an absolute timeout in seconds and nanoseconds
103 since the Epoch, 1970-01-01 00:00:00 +0000 (UTC),
104 specified in the following structure:
109 time_t tv_sec; /* seconds */
110 long tv_nsec; /* nanoseconds */
115 If the message queue is full,
116 and the timeout has already expired by the time of the call,
124 return zero; on error, \-1 is returned, with
126 set to indicate the error.
130 The queue was full, and the
132 flag was set for the message queue description referred to by
136 The descriptor specified in
138 was invalid or not opened for writing.
141 The call was interrupted by a signal handler; see
145 The call would have blocked, and
147 was invalid, either because
149 was less than zero, or because
151 was less than zero or greater than 1000 million.
157 attribute of the message queue.
160 The call timed out before a message could be transferred.
162 For an explanation of the terms used in this section, see
170 Interface Attribute Value
174 T} Thread safety MT-Safe
180 POSIX.1-2001, POSIX.1-2008.
184 is a system call, and
186 is a library function layered on top of that system call.