mq_setattr Subroutine

Purpose

Sets message queue attributes.

Library

Standard C Library (libc.a)

Syntax

#include <mqueue.h>

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

Description

The mq_setattr subroutine sets attributes associated with the open message queue description referenced by the message queue descriptor specified by mqdes.

The message queue attributes corresponding to the following members defined in the mq_attr structure are set to the specified values upon successful completion of the mq_setattr subroutine.

The value of the mq_flags member is either zero or O_NONBLOCK.

The values of the mq_maxmsg, mq_msgsize, and mq_curmsgs members of the mq_attr structure are ignored by the mq_setattr subroutine.

If the omqstat parameter is non-NULL, the mq_setattr subroutine stores, in the location referenced by omqstat, the previous message queue attributes and the current queue status. These values are the same as would be returned by a call to the mq_getattr subroutine at that point.

Parameters

Item Description
mqdes Specifies the message queue descriptor.
mqstat Specifies the status of the message queue.
omqstat Specifies the status of the previous message queue.

Return Values

Upon successful completion, the mq_setattr subroutine returns a zero and the attributes of the message queue are changed as specified.

Otherwise, the message queue attributes are unchanged, and the subroutine returns a -1 and sets errno to indicate the error.

Error Codes

The mq_setattr subroutine fails if:
Item Description
EBADF The mqdes parameter is not a valid message queue descriptor.
EFAULT Invalid user address.
EINVAL The mqstat parameter value is not valid.
ENOMEM Insufficient memory for the required operation.
ENOTSUP This function is not supported with processes that have been checkpoint-restart'ed.