mq_setattr()

Set the attributes for a message-queue descriptor

Synopsis:

#include <mqueue.h>

int mq_setattr( mqd_t mqdes, 
                const struct mq_attr* mqstat,
                struct mq_attr* omqstat );

Arguments:

mqdes
The message-queue descriptor, returned by mq_open(), that you want to set the attributes of.
mqstat
A pointer to an mq_attr structure that contains new attributes to use for the message-queue descriptor specified by mqdes. For information about this structure, see mq_getattr(); for information about which input fields in this structure get processed by mq_setattr(), see below.
omqstat
NULL, or a pointer to an mq_attr structure where the function can store the old attributes of the descriptor.

Library:

  • For the traditional implementation, libc:

    Use the -l c option to qcc to link against this library. This library is usually included automatically.

  • For the alternate implementation that uses the mq server and a queue in kernel space, libmq:

    Use the -l mq option to qcc to link against this library.

Description:

The mq_setattr() function updates some of the attributes of the given message-queue descriptor (mqdes). Specifically, this function sets the mq_flags field in the descriptor to the value of the mq_flags field in the attribute structure pointed to by mqstat. The new flags setting isn't applied to the queue itself, just to the queue descriptor. If omqstat isn't NULL, then the old attribute structure is stored in the location that this argument points to.

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.

This function ignores the other input fields in the mqstat structure. The mq_flags 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.

Returns:

-1 if the function couldn't change the attributes (errno is set). Any other value indicates success.

Errors:

EBADF
The message-queue descriptor does not correspond to an open queue.

Classification:

POSIX 1003.1 MSG

Safety:
Cancellation pointNo
Interrupt handlerNo
Signal handlerNo
ThreadYes
Page updated: