NAME | SYNOPSIS | FEATURES | DESCRIPTION | RETURN VALUE | ERRORS | ATTRIBUTES | SEE ALSO
#include <mqueue.h>int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio);
POSIX_MQ
The mq_send system call adds the message pointed to by the argument msg_ptr to the message queue specified by mqdes. The msg_len argument specifies the length of the message in bytes. The value of msg_len must be less than or equal to the mq_msgsize attribute of the message queue or mq_send will fail.
If the specified message queue is not full, mq_send will insert the message into the message queue at the position indicated by the msg_prio argument. A message with a larger numeric value of msg_prio is inserted before messages with lower values of msg_prio. A message will be inserted after other messages in the queue, if any, with equal msg_prio values. The value of msg_prio must be less than or equal to MQ_PRIO_MAX, as returned by sysconf(3POSIX).
If the specified message queue is full and O_NONBLOCK is not set in the message queue description associated with mqdes, mq_send will block until space becomes available to enqueue the message, or until mq_send is interrupted by a signal or a mq_close(2POSIX) operation is performed using the same message queue descriptor. If more than one thread is waiting to send when space becomes available in the message queue, the thread that has been waiting the longest will be unblocked to send its message. If the specified message queue is full and O_NONBLOCK is set in the message queue description associated with mqdes, the message is not queued, and mq_send returns an error.
Upon successful completion, mq_send returns a value of 0. Otherwise, no message will be enqueued, mq_send will return -1, and set errno to indicate one of the following error conditions.
The mq_send function is not supported.
The MQ feature [_POSIX_MESSAGE_PASSING] option (see sysconf(3POSIX)) is not configured.
The mqdes argument is not a valid message queue descriptor of a queue open for writing.
mq_send is blocked waiting for available space to enqueue the message and a mq_close(2POSIX) operation was performed using the same message queue descriptor.
The value of msg_prio was outside the valid range.
The O_NONBLOCK flag is set in the message queue description associated with mqdes and the message queue specified is full.
msg_ptr points outside the allocated address space of the c_actor.
The message length specified, msg_len, exceeds the message size attribute of the message queue.
A signal interrupted the call to mq_send.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | FEATURES | DESCRIPTION | RETURN VALUE | ERRORS | ATTRIBUTES | SEE ALSO