MsgQueueReceive()
QNX SDP8.0C Library ReferenceAPIDeveloper
Receive a message on an open queue
Note:
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, 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 will be copied to the priority buffer.
Returns:
- 0
- Success.
- -1
- An error occurred (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.
- 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:
Safety: | |
---|---|
Cancellation point | No |
Signal handler | Yes |
Thread | Yes |
Page updated: