3 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
9 .Nm mq_receive, mq_timedreceive
10 .Nd receive a message from a message queue (REALTIME)
20 .Fa "unsigned *msg_prio"
27 .Fa "char *restrict msg_ptr"
29 .Fa "unsigned *restrict msg_prio"
30 .Fa "const struct timespec *restrict abs_timeout"
35 function receives the oldest of the highest priority message(s)
36 from the message queue specified by
38 If the size of the buffer in bytes, specified by the
40 argument, is less than the
42 attribute of the message queue, the function fails and returns an error.
43 Otherwise, the selected message will be removed from the queue and copied
44 to the buffer pointed to by the
52 the priority of the selected message will be stored in the location
56 If the specified message queue is empty and
58 is not set in the message queue description associated with
61 blocks until a message is enqueued on the message queue or until
63 is interrupted by a signal.
64 If more than one thread is waiting to receive a message when a
65 message arrives at an empty queue, then the thread of highest
66 priority that has been waiting the longest will be selected to
68 If the specified message queue is empty and
70 is set in the message queue description associated with
72 no message will be removed from the queue, and
76 The timeout expires when the absolute time specified by
78 passes, as measured by the clock on which timeouts are based (that is,
79 when the value of that clock equals or exceeds
81 or if the absolute time specified by
83 has already been passed at the time of the call.
85 The resolution of the timeout is based on the CLOCK_REALTIME clock.
88 argument is defined in the
92 Under no circumstance will the operation fail with a timeout if a
93 message can be removed from the message queue immediately.
96 parameter will not be checked if a message can be removed from the
97 message queue immediately.
99 Upon successful completion, the
103 functions return a value of zero.
104 Otherwise, no message will be removed from the queue,
105 the functions return a value of
106 \-1, and set the global variable
108 to indicate the error.
118 was set in the message description associated with
120 and the specified message queue is empty.
124 argument is not a valid message queue descriptor open for reading.
130 operation was interrupted by a signal.
132 The process or thread would have blocked, and the
134 parameter specified a nanoseconds field value less than zero
135 or greater than or equal to 1000 million.
137 The specified message buffer size,
139 is less than the message size attribute of the message queue.
143 flag was not set when the message queue was opened,
144 but no message arrived on the queue before the specified timeout expired.
155 These functions are expected to conform to the
163 functions first appeared in
166 Portions of this text are reprinted and reproduced in electronic form
167 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
168 -- Portable Operating System Interface (POSIX), The Open Group Base
169 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
170 Electrical and Electronics Engineers, Inc and The Open Group.
172 event of any discrepancy between this version and the original IEEE and
173 The Open Group Standard, the original IEEE and The Open Group Standard
174 is the referee document.
175 The original Standard can be obtained online at
176 http://www.opengroup.org/unix/online.html .