Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I need help. I am relatively new to Linux. I have a program that uses message queue using the mq_open() call to create one. When the program is waiting for a message in the queue (blocking) and I abort the program using control-C, I am getting the ENOMEM error (cannot allocate memory) from mq_open() call after only repeating the scenario 3 to 4 times. I am aware that the message queue is persistent in the kernel and this causes memory leak. The only way to make it to work again is reboot the Linux machine. Is there a way that my program can check for any un-removed message queues and clean it up? But is the best solution for this type of problem? Thanks.
Someone please respond, I'm having the trouble too. I've caught the ctrl+c signal and I'm closing all the message queues at the destructor. But still the mq_open: cannot allocate memory problem exists. Have somebody figured this out? This is some old thread, has roxasmn found a remedy?
Thank you all for your very quick replies.
I have indeed used mq_unlink command to terminate the message queues.
Thanx for pointing out "ipcs" command. Now there's a major problem. In my program I create 2 threads which create message queues for communication. Still, when the program is running, "IPCS" command output doesn't show anything. It says no shared memory/MQ/Semaphore. I'm confused, does that mean my problem is not related to message queues? And why it doesn't show any message queues?
Bdw, I'm running the system on a arm based core
ipcs Shows system V message queues not POSIX message queues
If one process calls mq_unlink on a queue where another still has the queue open
then the resources allocated to the queue are not reclaimed until it is closed
by the second process. This can give ENOMEM errors when trying to create new queues.
You can use /proc to spot open queue descriptors for a process eg:
ls -l /proc/<pid>/fd
lr-x------ 1 steve steve 64 2011-08-10 16:08 4 -> /myq1
l-wx------ 1 steve steve 64 2011-08-10 16:09 5 -> /myq2 (deleted)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.