Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

mq_open(3P4)

mq_close(3P4)

mq_destroy(3P4)

mq_receive(3P4)

mq_getattr(3P4)

mq_notify(3P4)

mq_send(3P4)  —  CX/UX Programmer’s Reference Manual

NAME

mq_send − send a message to a message queue

SYNOPSIS

#include <mqueue.h>
int mq_send (mqdes, msg_ptr, msg_len, msg_prio);
mqd_t mqdes;
char ∗msg_ptr;
size_t msg_len;
unsigned int msg_prio;

DESCRIPTION

The mq_send() function adds the message that is pointed to by msg_ptr and is of length msg_len to the message queue specified by mqdes.  When the message queue was created, its attributes were defined via the mq_attr structure.  If the value of msg_len is greater than the value of the mq_msgsize member of the mq_attr structure that was used to create the message queue, mq_send() will fail. 

Messages sent to a message queue are ordered by message priority, which is specified by msg_prio.  Message priorities must be in the range zero to MQ_PRIO_MAX (defined in /usr/include/limits.h ).  A message with a higher numeric value of msg_prio has a more favorable priority than messages with lower numerical values of msg_prio.  Messages of the same priority are placed in the message queue in the order in which they are sent to the message queue. 

If the specified message queue is full and O_NONBLOCK is not set for the message queue descriptor specified by mqdes, mq_send() will block until space becomes available to queue the message, or until mq_send() is interrupted by a signal.  If more than one process is waiting to send when space becomes available in the message queue, then the process of the highest scheduling priority will be unblocked to send its message.  If the specified message queue is full and O_NONBLOCK is set in the message queue descriptor specified by mqdes, the message is not queued, and mq_send() returns an error. 

RETURN VALUE

Upon successful completion, the mq_send() function returns a zero.  If any of the following conditions occur, a −1 is returned and errno is set to indicate the error:

­[EAGAIN] O_NONBLOCK is set in the message queue description associated with mqdes, and this operation would have blocked because the message queue is full. 

­[EBADF] The mqdes argument is not a valid message queue descriptor open for writing. 

­[EMSGSIZE] The specified message length, msg_len, exceeds the message size attribute of the message queue. 

­[EINVAL] The specified priority, msg_prio, is not in the range of zero to MQ_PRIO_MAX. 

­[EINTR] A signal interrupted this mq_send().

FILES

/usr/lib/libposix4.a

SEE ALSO

mq_open(3P4), mq_close(3P4), mq_destroy(3P4), mq_receive(3P4), mq_getattr(3P4), mq_notify(3P4), "CX/UX Programmer’s Guide".

WARNING

The interface to mq_send() is based on IEEE Draft Standard P1003.4/D12.  This is an unapproved draft, subject to change.  Use of information contained in this unapproved draft is at your own risk.  This interface will change to reflect any changes made by future drafts of POSIX 1003.4. 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026