From b8bbeeda02b884b0d752aa284ed56c5b272409ce Mon Sep 17 00:00:00 2001 From: Daniel Eischen Date: Thu, 8 Apr 2004 23:16:21 +0000 Subject: After forking and initializing the library to single-threaded mode (where the forked thread is the one and only thread and is marked as system scope), set the system scope flag before initializing the signal mask. This prevents trying to use internal locks that haven't yet been initialized. Reported by: Dan Nelson Reviewed by: davidxu --- lib/libkse/thread/thr_kern.c | 5 +++-- lib/libpthread/thread/thr_kern.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/libkse/thread/thr_kern.c b/lib/libkse/thread/thr_kern.c index c72e915d1b69b..d9a5179c01bcc 100644 --- a/lib/libkse/thread/thr_kern.c +++ b/lib/libkse/thread/thr_kern.c @@ -347,13 +347,14 @@ _kse_single_thread(struct pthread *curthread) _thr_signal_deinit(); } __isthreaded = 0; + curthread->kse->k_kcb->kcb_kmbx.km_curthread = NULL; + curthread->attr.flags |= PTHREAD_SCOPE_SYSTEM; + /* * Restore signal mask early, so any memory problems could * dump core. */ sigprocmask(SIG_SETMASK, &curthread->sigmask, NULL); - curthread->kse->k_kcb->kcb_kmbx.km_curthread = NULL; - curthread->attr.flags |= PTHREAD_SCOPE_SYSTEM; _thr_active_threads = 1; #endif } diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c index c72e915d1b69b..d9a5179c01bcc 100644 --- a/lib/libpthread/thread/thr_kern.c +++ b/lib/libpthread/thread/thr_kern.c @@ -347,13 +347,14 @@ _kse_single_thread(struct pthread *curthread) _thr_signal_deinit(); } __isthreaded = 0; + curthread->kse->k_kcb->kcb_kmbx.km_curthread = NULL; + curthread->attr.flags |= PTHREAD_SCOPE_SYSTEM; + /* * Restore signal mask early, so any memory problems could * dump core. */ sigprocmask(SIG_SETMASK, &curthread->sigmask, NULL); - curthread->kse->k_kcb->kcb_kmbx.km_curthread = NULL; - curthread->attr.flags |= PTHREAD_SCOPE_SYSTEM; _thr_active_threads = 1; #endif } -- cgit v1.3