Boost logo

Boost Users :

From: yg-boost-users_at_[hidden]
Date: 2003-07-01 19:36:26


Pavol Droba <droba_at_[hidden]> writes:

| Hi,
|
| I have problem with boost.threads on linux ( under gcc ).
| I have a multithreaded aplication using Boost.Thread. It works just fine.
|
| However, I want to make a daemon out of it. So I tried to fork() at the start
| of the program and run all the relevant code ( including all threading ) in the
| child process. But when I do so, first call to create_thread hangs the process.

I use something like this:

int main(int argc, char * argv[])
{
        pid_t pid = -1;

        pid = fork();

        if (pid > 0) {
                // Parent
        } else {
                if (pid == 0) {
                        setsid();
                        close(0);
                        close(1);
                        close(2);
                        chdir("/");
                        umask(0);
                }
                signal(SIGPIPE, SIG_IGN);

                return child_main();
        }

        return EXIT_SUCCESS;
}

(the code has been changed a bit, error handling removed etc.)

and in child_main threads are created.

It might be that you are just missing the setsid call?

-- 
	Lgb

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net