# Posix Message Queue

**URL:** <https://forum.legato.io/t/posix-message-queue/58>\
**Category:** Legato Application Framework\
**Created:** [July 14, 2014, 12:48pm UTC](https://forum.legato.io/t/posix-message-queue/58 "2014-07-14T12:48:07Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![bvalletta](https://avatars.discourse-cdn.com/v4/letter/b/9fc29f/32.png) [@bvalletta](https://forum.legato.io/u/bvalletta)\
**Post date:** [July 14, 2014, 12:48pm UTC](https://forum.legato.io/t/posix-message-queue/58/1 "2014-07-14T12:48:07Z")

</div>

I am trying to create a POSIX message queue in one of my COMPONENT\_INIT functions and I am getting errno = 24 from the mq\_open() which is the EMFILE error code. But it is the only message queue that I am trying to create in my component and my process in general (currently 2 components).

I do issue a cat /proc/sys/fs/mqueue/queues\_max command it says 256, but I am only trying to open 1 queue. I am opening 1 other UART device (/dev/ttyHSL1).

Effectively I just want 1 component to set up the UART device and the other start a thread that waits on a message with serial data from the UART (invoking the mq\_send from the SIGIO signal handler).

What could be the cause of this error?

Thanks!

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.legato.io/u/davidc)\
**Post date:** [July 15, 2014, 3:50am UTC](https://forum.legato.io/t/posix-message-queue/58/2 "2014-07-15T03:50:23Z")

</div>

Hiya,

Are you running your application inside a sandbox? You might be running into permissions issues.

Try setting sandbox=false in your ADEF file.

ciao, Dave

---

<div class="post-metadata">

**Author:** ![bvalletta](https://avatars.discourse-cdn.com/v4/letter/b/9fc29f/32.png) [@bvalletta](https://forum.legato.io/u/bvalletta)\
**Post date:** [July 15, 2014, 11:35am UTC](https://forum.legato.io/t/posix-message-queue/58/3 "2014-07-15T11:35:06Z")

</div>

No, it is not sandboxed so it has to be something else…

---

<div class="post-metadata">

**Author:** ![ajiang](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@ajiang](https://forum.legato.io/u/ajiang)\
**Post date:** [July 18, 2014, 2:09am UTC](https://forum.legato.io/t/posix-message-queue/58/4 "2014-07-18T02:09:57Z")

</div>

Hi,

Is your process an app (does it have an adef file)? Which user are you running as? The rlimit RLIMIT\_NOFILE may be exceeded for you process.

Alex

---

<div class="post-metadata">

**Author:** ![bvalletta](https://avatars.discourse-cdn.com/v4/letter/b/9fc29f/32.png) [@bvalletta](https://forum.legato.io/u/bvalletta)\
**Post date:** [July 21, 2014, 3:28pm UTC](https://forum.legato.io/t/posix-message-queue/58/5 "2014-07-21T15:28:05Z")

</div>

Yes, the process is an app. I’m just running as the app’s user. And besides the device I’m opening it is the only file descriptor that I am opening and the rlimit is set to 256.

---

<div class="post-metadata">

**Author:** ![ajiang](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@ajiang](https://forum.legato.io/u/ajiang)\
**Post date:** [July 21, 2014, 6:41pm UTC](https://forum.legato.io/t/posix-message-queue/58/6 "2014-07-21T18:41:51Z")

</div>

I cannot reproduce your problem here. I am able to create message queues in sandboxed and unsandboxed apps. How do you start the app? If you could send me your adef and sources I can test it here.

---

<div class="post-metadata">

**Author:** ![bvalletta](https://avatars.discourse-cdn.com/v4/letter/b/9fc29f/32.png) [@bvalletta](https://forum.legato.io/u/bvalletta)\
**Post date:** [July 22, 2014, 11:54am UTC](https://forum.legato.io/t/posix-message-queue/58/7 "2014-07-22T11:54:08Z")

</div>

I am just installing and starting it through the Remote System Explorer in Developer Studio. I’ve just attached the whole project for you.

---

<div class="post-metadata">

**Author:** ![ajiang](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@ajiang](https://forum.legato.io/u/ajiang)\
**Post date:** [July 25, 2014, 6:21pm UTC](https://forum.legato.io/t/posix-message-queue/58/8 "2014-07-25T18:21:44Z")

</div>

The problem is that your application is exceeding the message queue size limit. If you add the following line to your adef it should work.

mqueueSize: 10240

---

<div class="post-metadata">

**Author:** ![bvalletta](https://avatars.discourse-cdn.com/v4/letter/b/9fc29f/32.png) [@bvalletta](https://forum.legato.io/u/bvalletta)\
**Post date:** [July 28, 2014, 6:53pm UTC](https://forum.legato.io/t/posix-message-queue/58/9 "2014-07-28T18:53:31Z")

</div>

I think that is the issue. But now when I set the mqueueSize to 10240 and install and start the application, I still get:

01:20:46 -WRN- | supervisor[724]/supervisor T=main | resourceLimits.c SetRLimit() 264 | No resource limit totalPosixMsgQueueSizeLimit. Using the default value 512.  
01:20:46 INFO | supervisor[724]/supervisor T=main | resourceLimits.c SetRLimit() 296 | Setting resource limit totalPosixMsgQueueSizeLimit to value 512.

output from the console

## I can lower mq\_msgsize and mq\_maxmsg so it totals under 512 bytes and I can open the message queue with no problems. Here’s what my adef file looks like, maybe I’m defining it wrong?

executables:  
Debug\_project ( “SerProcComponent” “dbgComponent” )

sandboxed: false

mqueueSize: 10240

processes:  
run: ( Debug\_project )

groups: dialout // Needed to access UARTs

---

<div class="post-metadata">

**Author:** ![ajiang](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@ajiang](https://forum.legato.io/u/ajiang)\
**Post date:** [July 29, 2014, 6:48pm UTC](https://forum.legato.io/t/posix-message-queue/58/10 "2014-07-29T18:48:04Z")

</div>

Your adef definition is right. I’ve tried it out here and it works. Are you running the latest Legato version from Github?

---

<div class="post-metadata">

**Author:** ![EvetsMostel](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@EvetsMostel](https://forum.legato.io/u/EvetsMostel)\
**Post date:** [June 12, 2020, 4:55pm UTC](https://forum.legato.io/t/posix-message-queue/58/11 "2020-06-12T16:55:50Z")

</div>

Hi have the same problem. When I put mqueueSize: 10240 in my adef, I get an error from the compiler error: Unrecognized section name ‘mqueueSize’.

Any thoughts on this?

Evets
