Boost logo

Boost :

From: Sami Väisänen (sami.vaisanen_at_[hidden])
Date: 2008-06-09 05:58:29


Hi,

I have an application that forks a child process. The child exists only
for a little while, (does dup2() calls to redirect stdout/stderr output
into pipes and then makes a system() call) and then exits with exit().
However at exit I get an assertion failure in boost.thread library (the
assertion happens in the child process)

 ../boost_1_34_1/libs/thread/src/condition.cpp:351:boost::detail::condition_impl::~condition_impl():
Assertion `res == 0'

I wrote a little test application in the hopes of being able to
reproduce the problem in smaller scale but naturally it doesn't happen
there. Regardless im asking here, whether anyone got any ideas about
what might be going wrong and how to go about fixing it.

Thanks,
- sami

ps. here's the code for the test application just in case

#include <cstdlib>
#include <iostream>
#include <boost/thread/condition.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/xtime.hpp>
#include <sys/types.h>
#include <unistd.h>

using namespace std;
using namespace boost;

int main()
{
    condition cond;
    mutex m;
    mutex::scoped_lock l(m);
    xtime xt;
    xtime_get(&xt, boost::TIME_UTC);
    xt.sec += 1;
    cond.timed_wait(l, xt);

    pid_t pid = fork();
    if (pid != 0)
    {
        cout << "parent sleeping...\n";
        sleep(10);
        return 0;
    }
   
    system("echo hello");
    cout << "child sleeping...\n";
    sleep(15);
    exit(0);
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk