Boost logo

Boost Users :

Subject: [Boost-users] Return value of bool boost::interprocess::shared_memory_object::remove(const char * name)
From: Jarno (jarno.leppanen_at_[hidden])
Date: 2010-01-05 22:23:17


Hello,

It seems to me that the static function bool remove(const char * name)
in class boost::interprocess::shared_memory_object returns false when it
should return true and vice versa.

The documentation on boost interprocess says:

"The remove operation might fail returning false if the shared memory
does not exist, the file is open or the file is still memory mapped by
other processes"

However, the following simple test program for example prints "should
not print" on Windows XP 64. I'm compiling with MSVC 2008 and using
boost 1.41.0.

/* Test program */

#include <boost/interprocess/shared_memory_object.hpp>
#include <iostream>

int main(int argc, char* argv[])
{
   using namespace boost::interprocess;
   using namespace std;
   {
     shared_memory_object shm(open_or_create, "foo", read_write);
   }
   if(shared_memory_object::remove("foo"))
     cout << "should print" << endl;
   if(shared_memory_object::remove("foo"))
     cout << "should not print" << endl;
   return 0;
}

/* Test program ends */

Am I interpreting the documentation correctly?

Regards,
Jarno


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net