1MQ_SEND(3) Linux Programmer's Manual MQ_SEND(3)
2
3
4
6 mq_send, mq_timedsend - send a message to a message queue
7
9 #include <mqueue.h>
10
11 mqd_t mq_send(mqd_t mqdes, const char *msg_ptr,
12 size_t msg_len, unsigned msg_prio);
13
14 #define _XOPEN_SOURCE 600
15 #include <time.h>
16 #include <mqueue.h>
17
18 mqd_t mq_timedsend(mqd_t mqdes, const char *msg_ptr,
19 size_t msg_len, unsigned msg_prio,
20 const struct timespec *abs_timeout);
21
22 Link with -lrt.
23
25 mq_send() adds the message pointed to by msg_ptr to the message queue
26 referred to by the descriptor mqdes. The msg_len argument specifies
27 the length of the message pointed to by msg_ptr; this length must be
28 less than or equal to the queue's mq_msgsize attribute. Zero-length
29 messages are allowed.
30
31 The msg_prio argument is a nonnegative integer that specifies the pri‐
32 ority of this message. Messages are placed on the queue in decreasing
33 order of priority, with newer messages of the same priority being
34 placed after older messages with the same priority.
35
36 If the message queue is already full (i.e., the number of messages on
37 the queue equals the queue's mq_maxmsg attribute), then, by default,
38 mq_send() blocks until sufficient space becomes available to allow the
39 message to be queued, or until the call is interrupted by a signal han‐
40 dler. If the O_NONBLOCK flag is enabled for the message queue descrip‐
41 tion, then the call instead fails immediately with the error EAGAIN.
42
43 mq_timedsend() behaves just like mq_send(), except that if the queue is
44 full and the O_NONBLOCK flag is not enabled for the message queue
45 description, then abs_timeout points to a structure which specifies a
46 ceiling on the time for which the call will block. This ceiling is an
47 absolute timeout in seconds and nanoseconds since the Epoch, 1970-01-01
48 00:00:00 +0000 (UTC), and it is specified in the following structure:
49
50 struct timespec {
51 time_t tv_sec; /* seconds */
52 long tv_nsec; /* nanoseconds */
53 };
54
55 If the message queue is full, and the timeout has already expired by
56 the time of the call, mq_timedsend() returns immediately.
57
59 On success, mq_send() and mq_timedsend() return zero; on error, -1 is
60 returned, with errno set to indicate the error.
61
63 EAGAIN The queue was empty, and the O_NONBLOCK flag was set for the
64 message queue description referred to by mqdes.
65
66 EBADF The descriptor specified in mqdes was invalid.
67
68 EINTR The call was interrupted by a signal handler; see signal(7).
69
70 EINVAL The call would have blocked, and abs_timeout was invalid, either
71 because tv_sec was less than zero, or because tv_nsec was less
72 than zero or greater than 1000 million.
73
74 EMSGSIZE
75 msg_len was greater than the mq_msgsize attribute of the message
76 queue.
77
78 ETIMEDOUT
79 The call timed out before a message could be transferred.
80
82 POSIX.1-2001.
83
85 On Linux, mq_timedsend() is a system call, and mq_send() is a library
86 function layered on top of that system call.
87
89 mq_close(3), mq_getattr(3), mq_notify(3), mq_open(3), mq_receive(3),
90 mq_unlink(3), feature_test_macros(7), mq_overview(7), time(7)
91
93 This page is part of release 3.25 of the Linux man-pages project. A
94 description of the project, and information about reporting bugs, can
95 be found at http://www.kernel.org/doc/man-pages/.
96
97
98
99Linux 2010-02-25 MQ_SEND(3)