Boost logo

Boost :

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


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)

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.

- 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";
        return 0;
    system("echo hello");
    cout << "child sleeping...\n";

Boost list run by bdawes at, gregod at, cpdaniel at, john at