MsgQueueReceive()

QNX SDP8.0C Library ReferenceAPIDeveloper

Receive a message on an open queue

CAUTION:
Don't use the MsgQueueReceive() kernel call directly; instead, use mq_receive().

Synopsis:

#include <sys/neutrino.h>

int MsgQueueReceive( int fd,
                     char* msg,
                     size_t msglen,
                     unsigned* priority );

Arguments:

fd
A coid that identifies the open queue to receive a message on.
msg
A pointer to a buffer to store the received message in.
msglen
The length of the buffer. This must be at least as large as the queue's mq_msgsize.
priority
NULL, or a pointer to memory for storing the message priority.

Library:

libc

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

Description:

The MsgQueueReceive() kernel call dequeues a message from the message queue specified by fd. If the queue is empty and O_NONBLOCK was not specified in the call to MsgQueueOpen(), then the calling thread enters the STATE_MQ_RECEIVE state, indicating it is blocked while waiting for a message to be sent on the queue. If O_NONBLOCK was specified, the call does not block and instead returns EAGAIN. Upon successful dequeueing of a message, the contents are copied into the caller's msg buffer and if the priority pointer is not NULL, then the priority is copied into the buffer that the pointer refers to.

Returns:

The size of the message removed from the queue. If the call fails, -1 is returned as the size, no message is removed from the queue (except when a fault occurs while receiving, in which case the message is lost), and errno is set.

Errors:

EAGAIN
The queue is empty and O_NONBLOCK was set.
EBADF
One of the following errors occured:
  • The fd is not associated with a message queue.
  • The fd is not open for reading.
EFAULT
At least one of msg or priority isn't a valid pointer.
EINTR
The operation was interrupted by a signal.
EMSGSIZE
The buffer size is less than the mq_msgsize configured for the queue.
ETIMEDOUT
The queue is empty and a timeout expired.

Classification:

QNX OS

Safety:
Cancellation pointNo
Signal handlerYes
ThreadYes
Page updated: