I am stuck with quite a strange error in message queue code which used to work completely fine before. The error I am getting is :
terminate called after throwing an instance of 'std::runtime_error'
what(): Unable to create named message queue
The code which is throwing the error is:
void VMGR::initialize_mq()
{
int errsv;
queue_attr.mq_flags = 0;
queue_attr.mq_maxmsg = 10;
queue_attr.mq_msgsize = api::msg_sz;
queue_attr.mq_curmsgs = 0;
mq_unlink (api::nm_mqueue);
mq_close(queue);
queue = mq_open( api::nm_mqueue, O_RDWR | O_CREAT | O_EXCL|O_NONBLOCK, IO_FILE_PERMISSIONS, &queue_attr );
if (queue == (mqd_t)-1)
{
errsv = errno;
throw std::runtime_error(
std::string( "Unable to create named message queue" )
);
}
std::cout<< "initialize_mq works"<< std::endl;
return;
}
I have checked thoroughly the /dev/mqueue that I am not using the same file descriptor which already exists. Wasted a lot of time on resolving this error. Need help and guidance. Edit After executing ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 1030932
max locked memory (kbytes, -l) 65536
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 1030932
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
The number of message queue identifiers presently I have in the system:
Data7aa vmgr_proc135978 vmgr_proc40571 vmgr_proc55053
Data7bb vmgr_proc136146 vmgr_proc42152 vmgr_proc56557
Data7cc vmgr_proc136536 vmgr_proc43732 vmgr_proc9190
Data7dd vmgr_proc16914 vmgr_proc45247 vmgr_proc93026
Data7ee vmgr_proc17107 vmgr_proc46576 vmgr_proc9362
Data7gg vmgr_proc21970 vmgr_proc47958 vmgr_proc93706
Data7hh vmgr_proc29728 vmgr_proc49422 vmgr_proc93925
hello_moto vmgr_proc31111 vmgr_proc49700 vmgr_proc94596
vmgr_proc123434 vmgr_proc32504 vmgr_proc51452 vmgr_proc9528
vmgr_proc132441 vmgr_proc35308 vmgr_proc51869 vmgr_send
vmgr_proc132550 vmgr_proc39121 vmgr_proc53478