Ticket #2391: bug.cc

File bug.cc, 672 bytes (added by Sergey Samsonik <serge_98@…>, 14 years ago)

source code to demonstrate the problem

Line 
1#include <sys/wait.h>
2#include <stdlib.h>
3#include <boost/interprocess/managed_shared_memory.hpp>
4
5int main( int argc, const char* argv[])
6{
7 boost::interprocess::shared_memory_object::remove( "MySharedMemory");
8 boost::interprocess::managed_shared_memory segment(
9 boost::interprocess::create_only, "MySharedMemory", 4096);
10 pid_t child = fork();
11
12 printf( "%s pthread_self %ld\n", child? "parent": "child", pthread_self());
13
14 for( int i = 0; i < 1000000; ++i)
15 int *myclass = segment.find< int>( "aaa").first;
16
17 printf( "Done %s\n", child? "parent": "child");
18
19 if( 0 == child)
20 return 0;
21 wait( NULL);
22
23 printf( "All Done\n");
24}
25