Posix Message Queue


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?




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


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



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.



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.


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.


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


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


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?

Debug_project ( “SerProcComponent” “dbgComponent” )

sandboxed: false

mqueueSize: 10240

run: ( Debug_project )

groups: dialout // Needed to access UARTs


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