mq_getattr()
Get the attributes for a message-queue descriptor and the underlying message queue
Synopsis:
#include <mqueue.h>
int mq_getattr( mqd_t mqdes,
struct mq_attr* mqstat );
Arguments:
- mqdes
- The descriptor, returned by mq_open(), of the message queue that you want to get the attributes of.
- mqstat
- A pointer to an mq_attr structure where the function can store the attributes of the descriptor and of the underlying queue. For information about this structure, see below.
Library:
Description:
The mq_getattr() function gets the flag indicating whether reads or writes on the queue can block when using the mqdes descriptor, and the attributes of the underlying message queue. The attributes and the flag are stored in the location pointed to by mqstat.
Note:
The message queue manager needs to be running. QNX Neutrino supports two
implementations of message queues: a traditional implementation, and an alternate one that
uses the mq server and a queue in kernel space. For more information, see
the entries for mq and mqueue in the Utilities Reference, as well as
the POSIX Message Queues: Two Implementations technote.
The fields of the mq_attr structure are as follows:
- long mq_flags
- The flags currently set for the mqdes message-queue descriptor
(i.e., not the queue itself). These flags might have been changed by call to
mq_setattr()
since you opened the queue.
This field is the bitwise OR of zero or more of the following constants:
- O_NONBLOCK — no mq_receive() or mq_send() call will ever block on this queue when this descriptor is used. If the queue is in such a condition that the given receive or send operation can't be performed without blocking, then an error is returned, and errno is set to EAGAIN.
- long mq_maxmsg
- The maximum number of messages that can be stored on the queue. This value was set when the queue was created.
- long mq_msgsize
- The maximum size of each message on the message queue. This value was also set when the queue was created.
- long mq_curmsgs
- The number of messages currently on the given queue.
- long mq_sendwait
- The number of threads currently waiting to send a message. This field is a QNX Neutrino extension. A nonzero value implies that the queue is full.
- long mq_recvwait
- The number of threads currently waiting to receive a message. This field is a QNX Neutrino extension. A nonzero value implies that the queue is empty.
Note:
The alternate (mq) implementation of message queues doesn't
see the non-POSIX mq_sendwait and mq_recvwait fields.
Returns:
-1 if an error occurred (errno is set). Any other value indicates success.
Errors:
- EBADF
- The message-queue descriptor does not correspond to an open queue.
Examples:
See the example for mq_open().
Classification:
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | No |
| Thread | Yes |
Page updated:
