mq_send - send a message to a message queue (REALTIME)
#include <mqueue.h> int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio);
The mq_send() function 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 pointed to by msg_ptr. The value of msg_len is less than or equal to the mq_msgsize attribute of the message queue, or mq_send() fails.If the specified message queue is not full, mq_send() behaves as if the message is inserted 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. The value of msg_prio will be less than MQ_PRIO_MAX.
If the specified message queue is full and O_NONBLOCK is not set in the message queue description associated with mqdes, mq_send() blocks until space becomes available to enqueue the message, or until mq_send() is interrupted by a signal. If more than one thread is waiting to send when space becomes available in the message queue and the Priority Scheduling option is supported, then the thread of the highest priority that has been waiting the longest will be unblocked to send its message. Otherwise, it is unspecified which waiting thread is unblocked. 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, the mq_send() function returns a value of zero. Otherwise, no message is enqueued, the function returns -1, and is set to indicate the error.
The mq_send() function will fail if:
- [EAGAIN]
- The O_NONBLOCK flag is set in the message queue description associated with mqdes, and the specified message queue is full.
- [EBADF]
- The mqdes argument is not a valid message queue descriptor open for writing.
- [EINTR]
- A signal interrupted the call to mq_send().
- [EINVAL]
- The value of msg_prio was outside the valid range.
- [EMSGSIZE]
- The specified message length, msg_len, exceeds the message size attribute of the message queue.
- [ENOSYS]
- The function mq_send() is not supported by this implementation.
None.
None.
mq_receive(), mq_setattr(), <mqueue.h>.
Derived from the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995)