[omniORB] ORB_init after fork() no worky?

Dan Kegel dank@kegel.com
Wed, 20 Feb 2002 09:46:07 -0800


Duncan Grisby wrote:
> 
> On Wednesday 20 February, Dan Kegel wrote:
> 
> >   ORB_init() hangs if you fork first.
> >
> > Platform:
> >
> >   Red Hat 7.2 Intel.
> 
> I don't have any RedHat 7 machines handy. The problem doesn't occur
> with RedHat 6.2.
> 
> It's freezing when it tries to create a thread. I assume there's
> something broken about RedHat 7's pthreads. Have you got the latest
> versions of glibc and packages like that?

Hmm, I am up to date with respect to Red Hat 7.2's patches as of
a month after it's release, so probably close enough.
The test also fails on a Debian Testing system which is up to
date as of a couple months ago.  I suppose I could bring my
Debian system totally up to date.

A second test, that simply tests thread creation after fork, does
work properly.
So I can't reproduce the problem with a
trivial C test program.  Ditto with a very similar C++ program.
Might it be an unfortunate interaction of omniorb with modern glibc?
Which distributions did you test with?
- Dan

p.s. here's the trivial C test program that does work properly:

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <pthread.h>
#include <time.h>

struct timespec twomin;

void *threadMain(void *foo)
{
        write(1, "Started\n", 8);
        nanosleep(&twomin, NULL);
        return foo;
}

int main(int argc, char **argv)
{
        pid_t childpid;
        pthread_t t;

        twomin.tv_sec = 120;
        twomin.tv_nsec = 0;

        childpid = fork();

        if (childpid == 0) {
                write(1, "Forked\n", 7);
                pthread_create(&t, NULL, threadMain, NULL);
                write(1, "Done\n", 5);
        } else {
                nanosleep(&twomin, NULL);
        }
        return 0;
}