1MQ_SEND(3)                 Linux Programmer's Manual                MQ_SEND(3)
2
3
4

NAME

6       mq_send, mq_timedsend - send a message to a message queue
7

SYNOPSIS

9       #include <mqueue.h>
10
11       int mq_send(mqd_t mqdes, const char *msg_ptr,
12                     size_t msg_len, unsigned msg_prio);
13
14       #include <time.h>
15       #include <mqueue.h>
16
17       int mq_timedsend(mqd_t mqdes, const char *msg_ptr,
18                     size_t msg_len, unsigned msg_prio,
19                     const struct timespec *abs_timeout);
20
21       Link with -lrt.
22
23   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
24
25       mq_timedsend():
26           _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L
27

DESCRIPTION

29       mq_send()  adds  the message pointed to by msg_ptr to the message queue
30       referred to by the descriptor mqdes.  The  msg_len  argument  specifies
31       the  length  of  the message pointed to by msg_ptr; this length must be
32       less than or equal to the queue's  mq_msgsize  attribute.   Zero-length
33       messages are allowed.
34
35       The  msg_prio argument is a nonnegative integer that specifies the pri‐
36       ority of this message.  Messages are placed on the queue in  decreasing
37       order  of  priority,  with  newer  messages  of the same priority being
38       placed after older messages with the same priority.
39
40       If the message queue is already full (i.e., the number of  messages  on
41       the  queue  equals  the queue's mq_maxmsg attribute), then, by default,
42       mq_send() blocks until sufficient space becomes available to allow  the
43       message to be queued, or until the call is interrupted by a signal han‐
44       dler.  If the O_NONBLOCK flag is enabled for the message queue descrip‐
45       tion, then the call instead fails immediately with the error EAGAIN.
46
47       mq_timedsend() behaves just like mq_send(), except that if the queue is
48       full and the O_NONBLOCK flag is  not  enabled  for  the  message  queue
49       description,  then  abs_timeout points to a structure which specifies a
50       ceiling on the time for which the call will block.  This ceiling is  an
51       absolute timeout in seconds and nanoseconds since the Epoch, 1970-01-01
52       00:00:00 +0000 (UTC), and it is specified in the following structure:
53
54           struct timespec {
55               time_t tv_sec;        /* seconds */
56               long   tv_nsec;       /* nanoseconds */
57           };
58
59       If the message queue is full, and the timeout has  already  expired  by
60       the time of the call, mq_timedsend() returns immediately.
61

RETURN VALUE

63       On  success,  mq_send() and mq_timedsend() return zero; on error, -1 is
64       returned, with errno set to indicate the error.
65

ERRORS

67       EAGAIN The queue was full, and the O_NONBLOCK flag was set for the mes‐
68              sage queue description referred to by mqdes.
69
70       EBADF  The descriptor specified in mqdes was invalid.
71
72       EINTR  The call was interrupted by a signal handler; see signal(7).
73
74       EINVAL The call would have blocked, and abs_timeout was invalid, either
75              because tv_sec was less than zero, or because tv_nsec  was  less
76              than zero or greater than 1000 million.
77
78       EMSGSIZE
79              msg_len was greater than the mq_msgsize attribute of the message
80              queue.
81
82       ETIMEDOUT
83              The call timed out before a message could be transferred.
84

CONFORMING TO

86       POSIX.1-2001.
87

NOTES

89       On Linux, mq_timedsend() is a system call, and mq_send() is  a  library
90       function layered on top of that system call.
91

SEE ALSO

93       mq_close(3),  mq_getattr(3),  mq_notify(3),  mq_open(3), mq_receive(3),
94       mq_unlink(3), mq_overview(7), time(7)
95

COLOPHON

97       This page is part of release 3.53 of the Linux  man-pages  project.   A
98       description  of  the project, and information about reporting bugs, can
99       be found at http://www.kernel.org/doc/man-pages/.
100
101
102
103Linux                             2010-09-20                        MQ_SEND(3)
Impressum