1MQ_SEND(3P)                POSIX Programmer's Manual               MQ_SEND(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       mq_send, mq_timedsend — send a message to a message queue (REALTIME)
13

SYNOPSIS

15       #include <mqueue.h>
16
17       int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
18           unsigned msg_prio);
19
20       #include <mqueue.h>
21       #include <time.h>
22
23       int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
24           unsigned msg_prio, const struct timespec *abstime);
25

DESCRIPTION

27       The mq_send() function shall add the message pointed to by the argument
28       msg_ptr  to the message queue specified by mqdes.  The msg_len argument
29       specifies the length of the message, in bytes, pointed to  by  msg_ptr.
30       The  value  of  msg_len  shall  be less than or equal to the mq_msgsize
31       attribute of the message queue, or mq_send() shall fail.
32
33       If the specified message queue is not full, mq_send() shall  behave  as
34       if the message is inserted into the message queue at the position indi‐
35       cated by the msg_prio argument. A message with a larger  numeric  value
36       of  msg_prio  shall  be  inserted  before messages with lower values of
37       msg_prio.  A message shall be inserted  after  other  messages  in  the
38       queue,  if  any,  with  equal msg_prio.  The value of msg_prio shall be
39       less than {MQ_PRIO_MAX}.
40
41       If the specified message queue is full and O_NONBLOCK is not set in the
42       message  queue description associated with mqdes, mq_send() shall block
43       until  space  becomes  available  to  enqueue  the  message,  or  until
44       mq_send()  is interrupted by a signal. If more than one thread is wait‐
45       ing to send when space becomes available in the message queue  and  the
46       Priority Scheduling option is supported, then the thread of the highest
47       priority that has been waiting the longest shall be unblocked  to  send
48       its  message.  Otherwise,  it  is  unspecified  which waiting thread is
49       unblocked. If the specified message queue is full and O_NONBLOCK is set
50       in  the  message  queue  description associated with mqdes, the message
51       shall not be queued and mq_send() shall return an error.
52
53       The mq_timedsend() function shall add a message to  the  message  queue
54       specified  by  mqdes  in the manner defined for the mq_send() function.
55       However, if the specified message queue is full and O_NONBLOCK  is  not
56       set  in  the  message queue description associated with mqdes, the wait
57       for sufficient room in the queue shall be terminated when the specified
58       timeout expires. If O_NONBLOCK is set in the message queue description,
59       this function shall be equivalent to mq_send().
60
61       The timeout shall expire when the absolute time  specified  by  abstime
62       passes,  as measured by the clock on which timeouts are based (that is,
63       when the value of that clock equals or  exceeds  abstime),  or  if  the
64       absolute  time specified by abstime has already been passed at the time
65       of the call.
66
67       The timeout shall be based on the CLOCK_REALTIME clock.  The resolution
68       of  the  timeout  shall  be  the resolution of the clock on which it is
69       based. The timespec argument is defined in the <time.h> header.
70
71       Under no circumstance shall the operation fail with a timeout if  there
72       is  sufficient  room  in  the queue to add the message immediately. The
73       validity of the abstime parameter need not be  checked  when  there  is
74       sufficient room in the queue.
75

RETURN VALUE

77       Upon  successful completion, the mq_send() and mq_timedsend() functions
78       shall return a value of zero. Otherwise, no message shall be  enqueued,
79       the  functions  shall return -1, and errno shall be set to indicate the
80       error.
81

ERRORS

83       The mq_send() and mq_timedsend() functions shall fail if:
84
85       EAGAIN The O_NONBLOCK flag is set  in  the  message  queue  description
86              associated with mqdes, and the specified message queue is full.
87
88       EBADF  The  mqdes argument is not a valid message queue descriptor open
89              for writing.
90
91       EINTR  A signal interrupted the call to mq_send() or mq_timedsend().
92
93       EINVAL The value of msg_prio was outside the valid range.
94
95       EINVAL The process or thread would have blocked, and the abstime param‐
96              eter  specified  a  nanoseconds  field  value  less than zero or
97              greater than or equal to 1000 million.
98
99       EMSGSIZE
100              The specified message length, msg_len, exceeds the message  size
101              attribute of the message queue.
102
103       ETIMEDOUT
104              The  O_NONBLOCK  flag  was  not  set  when the message queue was
105              opened, but the timeout expired  before  the  message  could  be
106              added to the queue.
107
108       The following sections are informative.
109

EXAMPLES

111       None.
112

APPLICATION USAGE

114       The  value  of  the  symbol {MQ_PRIO_MAX} limits the number of priority
115       levels supported by the application.  Message priorities range  from  0
116       to {MQ_PRIO_MAX}-1.
117

RATIONALE

119       None.
120

FUTURE DIRECTIONS

122       None.
123

SEE ALSO

125       mq_open(), mq_receive(), mq_setattr(), time()
126
127       The Base Definitions volume of POSIX.1‐2017, <mqueue.h>, <time.h>
128
130       Portions  of  this text are reprinted and reproduced in electronic form
131       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
132       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
133       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
134       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
135       event of any discrepancy between this version and the original IEEE and
136       The  Open Group Standard, the original IEEE and The Open Group Standard
137       is the referee document. The original Standard can be  obtained  online
138       at http://www.opengroup.org/unix/online.html .
139
140       Any  typographical  or  formatting  errors that appear in this page are
141       most likely to have been introduced during the conversion of the source
142       files  to  man page format. To report such errors, see https://www.ker
143       nel.org/doc/man-pages/reporting_bugs.html .
144
145
146
147IEEE/The Open Group                  2017                          MQ_SEND(3P)
Impressum