I am facing a problem in using boost::recursive_mutex.

Flow of my program is:-
  1. Get a boost::recursive_mutex lock
  2. Fork the process
  3. In parent sleep for few seconds and then unlock boost::recursive_mutex.
  4. In child call exit(0)
What is happening is that child process is calling the destructor of boost::recursive_mutex and core is dumped. I want that child process should not inherit the boost mutex lock of parent.
Please tell me how to do it.

Please find attached the core, binary file and the source files.


Stack of core dumped


Thread 1 (Thread 32305):
#0  0x0000003bb9c30265 in raise () from /lib64/libc.so.6
#1  0x0000003bb9c31d10 in abort () from /lib64/libc.so.6
#2  0x0000003bb9c296e6 in __assert_fail () from /lib64/libc.so.6
#3  0x0000000000401224 in boost::recursive_mutex::~recursive_mutex (this=0x602c40, __in_chrg=<value optimized out>)
    at /installs/boost/boost_1_39_0/include/boost-1_39/boost/thread/pthread/recursive_mutex.hpp:62
#4  0x0000000000400f08 in __tcf_1 () at ../BoostTestClass.cpp:10
#5  0x0000003bb9c333a5 in exit () from /lib64/libc.so.6
#6  0x0000000000400f69 in main () at ../BoostTestClass.cpp:29


--
Thanks and Regards
Prashant Gour
Software Engineer
Drishti-Soft Solutions Pvt. Ltd.