---
name: "rt_mq_receive"
section: "2"
platform: "linux"
package: "rtlinux"
version: "2.0rel-1"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/rt_mq_receive"
---

# rt\_mq\_receive(2)

message queue 'receive' operation

## NAME

rt\_mq\_receive - message queue 'receive' operation

## SYNOPSIS

```
#define MODULE
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/errno.h>
#include rt_ipc.h
```

**int rt\_mq\_receive(rt\_mq\_t \****mq***, char \****msg***, RTIME** *wait***);**

## DESCRIPTION

**rt\_mq\_receive** dequeues the data *msg* from the message queue *mq*. The data will be of the size with which **rt\_mq\_init** was called. An optional timeout can be specified.  If  *wait* is RT\_WAIT\_FOREVER, the function does not time out.  If *wait* is RT\_NO\_WAIT and the semaphore is not available, **rt\_mq\_receive** returns immediately.  If *wait* is any other value, it represent a time at which the call to **rt\_mq\_receive** should time out.  If that time is reached, **rt\_mq\_receive** returns with -ETIME.

## RETURN VALUE

On success, 0 is returned.  On failure, a negative value is returned as described below.

## ERRORS

- **-ETIME**

  The timeout period expired.

- **-EAGAIN**

  *wait* was RT\_NO\_WAIT, and no data was available for dequeueing.

- **-EINVAL**

  *mq* does not point to a valid rt\_mq\_t.

## AUTHOR

Jerry Epplin \<JerryEpplin@worldnet.att.net\>

## SEE ALSO

[**rt\_mq\_destroy**(2)](/rt_mq_destroy/2.md), [**rt\_mq\_init**(2)](/rt_mq_init/2.md), [**rt\_mq\_send**(2)](/rt_mq_send/2.md), [**rt\_task\_ipc\_delete**(2)](/rt_task_ipc_delete/2.md), [**rt\_task\_ipc\_init**(2)](/rt_task_ipc_init/2.md)
