Boost::interprocess::message_queue权限被拒绝

boost::interprocess::message_queue permission denied

本文关键字:权限 拒绝 queue interprocess message Boost      更新时间:2023-10-16

所以我有下面的代码与boost 1.47:

try
{
  m_messageQueue = boost::shared_ptr<boost::interprocess::message_queue>(
           new boost::interprocess::message_queue (
             boost::interprocess::open_or_create
             ,name.c_str()             //name
             ,numElements              //max message number
             ,sizeof(Message)          //max message size
             ));
}
catch(boost::interprocess::interprocess_exception &e)
{
  cerr << e.what();
}

where name="test_queue", numElements=100, sizeof(Message)=256.

输出如下:没有权限

如果我以root用户运行,它将通过。我不知道它要写到哪里,哪里会有权限错误。看看boost代码,它不应该只是在/tmp/boost_interprocess中,任何用户都可以访问它来创建和写入吗?另外,我注意到https://svn.boost.org/trac/boost/ticket/4250,但是现在应该修复了。

我使用的是Centos 5.5。对我来说,需要将运行队列的用户的掩码设置为022。当我在。bashrc中设置后,所有工作都如预期的那样。