summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/thread.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/thread.cc')
-rw-r--r--winsup/cygwin/thread.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index a18834ddf..3652a91fa 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -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 = pthread_null::get_null_pthread ();
+ else
+ {
+ thread = new pthread ();
+ if (!thread)
+ api_fatal ("failed to create mainthread object");
+ }
}
thread->cygtls = &_my_tls;