I want to write a simple application with boost that passes string object to other process. It compiles well, but when i try to print out string from second process, following messages are put to console and second process crashes:
../boost_1_44_0/boost/interprocess/sync/posix/interprocess_recursive_mutex.hpp:107: void boost::interprocess::interprocess_recursive_mutex::unlock(): Assertion `res == 0' failed.
first process code:
shared_memory_object::remove(SHARED_MEMORY_NAME);
managed_shared_memory mshm(create_only, SHARED_MEMORY_NAME, SHARED_MEMORY_SIZE );
mshm.construct<string>( IP_STRING_NAME )("Message to other process");
string syscall(argv[0]);
std::system( (syscall+" &").c_str() ); //starting second process
second process code:
managed_shared_memory mshm( open_or_create, SHARED_MEMORY_NAME, SHARED_MEMORY_SIZE );
std::pair<string * , size_t > p= mshm.find<string>(IP_STRING_NAME);
cout<<"string is "<<*p.first<<endl;
How can i make my application work in proper way ?
See Question&Answers more detail:os