diff -urp cygwin.org/thread.cc cygwin/thread.cc --- cygwin.org/thread.cc 2004-03-30 16:13:57.664116800 +0200 +++ cygwin/thread.cc 2004-03-30 16:24:15.261008000 +0200 @@ -153,7 +153,7 @@ MTinterface::fixup_after_fork (void) pthread_key::fixup_after_fork (); threadcount = 0; - pthread::init_mainthread (); + pthread::init_mainthread (true); pthread::fixup_after_fork (); pthread_mutex::fixup_after_fork (); @@ -166,14 +166,19 @@ MTinterface::fixup_after_fork (void) /* static methods */ void -pthread::init_mainthread () +pthread::init_mainthread (const bool forked) { pthread *thread = get_tls_self_pointer (); if (!thread) { - thread = new pthread (); - if (!thread) - api_fatal ("failed to create mainthread object"); + if (!forked) + { + thread = new pthread (); + if (!thread) + api_fatal ("failed to create mainthread object"); + } + else + thread = pthread_null::get_null_pthread (); } thread->cygtls = &_my_tls; diff -urp cygwin.org/thread.h cygwin/thread.h --- cygwin.org/thread.h 2004-03-30 16:14:12.875990400 +0200 +++ cygwin/thread.h 2004-03-30 16:24:15.351137600 +0200 @@ -373,7 +373,7 @@ public: pthread (); virtual ~pthread (); - static void init_mainthread (); + static void init_mainthread (const bool forked = false); static bool is_good_object(pthread_t const *); static void atforkprepare(); static void atforkparent();