1mq_send(3)                 Library Functions Manual                 mq_send(3)
2
3
4

NAME

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

LIBRARY

9       Real-time library (librt, -lrt)
10

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

ATTRIBUTES

84       For an explanation of the terms used in this section, see at‐
85       tributes(7).
86
87       ┌────────────────────────────────────────────┬───────────────┬─────────┐
88Interface                                   Attribute     Value   
89       ├────────────────────────────────────────────┼───────────────┼─────────┤
90mq_send(), mq_timedsend()                   │ Thread safety │ MT-Safe │
91       └────────────────────────────────────────────┴───────────────┴─────────┘
92

VERSIONS

94       On  Linux,  mq_timedsend() is a system call, and mq_send() is a library
95       function layered on top of that system call.
96

STANDARDS

98       POSIX.1-2008.
99

HISTORY

101       POSIX.1-2001.
102

SEE ALSO

104       mq_close(3), mq_getattr(3),  mq_notify(3),  mq_open(3),  mq_receive(3),
105       mq_unlink(3), timespec(3), mq_overview(7), time(7)
106
107
108
109Linux man-pages 6.04              2023-03-30                        mq_send(3)
Impressum