MsgQueueCtl()

QNX SDP8.0C Library ReferenceAPIDeveloper

Perform message queue operations

Synopsis:

#include <sys/neutrino.h>

int MsgQueueCtl( int fd,
                 int cmd,
                 void* data );

Arguments:

fd
The open queue descriptor, as obtained with mq_open().
cmd
The operation to perform, specified by one the following constants:
  • _NTO_MQCTL_NOTIFY — Register the caller for notification when the queue identified by fd transitions from an empty to non-empty state. In this case, data must be a pointer to a sigevent structure.
  • _NTO_MQCTL_GETATTR — Fill in an mq_attr structure with the queue attributes (see mq_getattr() for information about the contents of the mq_attr structure).
  • _NTO_MQCTL_SETATTR — Change the attributes of a message queue.
  • _NTO_MQCTL_GETBUFSIZE — Calculate the buffer size needed to store a message queue with the specified maximum number of messages and maximum message size. The fd argument must be -1 for this command. For more information, see the data argument.
data
A pointer to the appropriate data structure for the current operation:
  • _NTO_MQCTL_NOTIFY — a sigevent structure
  • _NTO_MQCTL_GETATTR — a struct mq_attr structure
  • _NTO_MQCTL_SETATTR — a struct mq_attr structure
  • _NTO_MQCTL_GETBUFSIZE — a struct _mqctl_getbufsize structure with the following settings:
    • __in.__msgsize — the maximum size, in bytes, of any message in the queue
    • __in.__maxmsg — the maximum number of messages in the queue
    These two input fields must be defined because the required buffer size depends on both of them. A message queue created with default parameters has a maximum message size of 4096 bytes and a maximum of 1024 messages, as mentioned in the mq_open() reference. The required buffer size, which includes the overhead added by the kernel, is stored in the __out.__bufsize field of this structure when the function returns successfully.

Library:

libc

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

Description:

The MsgQueueCtl() function is used to perform operations on message queues. These operations include registering for notifications, querying queue attributes, and changing the blocking state of the queue connection.

Note:
This kernel call is used to implement the C library functions mq_notify(), mq_getattr(), and mq_setattr(). It should not be used directly, except for the _NTO_MQCTL_GETBUFSIZE command.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

ENOSYS
An unsupported command was specified.
EBADF
The queue descriptor does not correspond to an open queue.
EBUSY
_NTO_MQCTL_NOTIFY attempted to add a notification for a queue where a notification already exists.
EINVAL
_NTO_MQCTL_NOTIFY attempted to remove a notification that was added by a different process.

Classification:

QNX OS

Safety:
Cancellation pointNo
Signal handlerYes
ThreadYes
Page updated: