summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2003-09-04 05:24:53 +0000
committerdavidxu <davidxu@FreeBSD.org>2003-09-04 05:24:53 +0000
commit962cbaebac20fb27c3c319ff32b2365bb1f90c5d (patch)
tree578790928fa058fe007e5decec376b20dbbe76af /lib
parent06abe0101f42bafaf0730cd7bfec92ea592b1f4d (diff)
downloadFreeBSD-src-962cbaebac20fb27c3c319ff32b2365bb1f90c5d.zip
FreeBSD-src-962cbaebac20fb27c3c319ff32b2365bb1f90c5d.tar.gz
Allow hooks registered by atexit() to run with current thread pointer set,
without this change, my atexit test dumps core.
Diffstat (limited to 'lib')
-rw-r--r--lib/libkse/thread/thr_kern.c5
-rw-r--r--lib/libpthread/thread/thr_kern.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/libkse/thread/thr_kern.c b/lib/libkse/thread/thr_kern.c
index f9a17a5..5ed144a 100644
--- a/lib/libkse/thread/thr_kern.c
+++ b/lib/libkse/thread/thr_kern.c
@@ -1246,7 +1246,6 @@ thr_cleanup(struct kse *curkse, struct pthread *thread)
KSE_SCHED_UNLOCK(curkse, curkse->k_kseg);
DBG_MSG("Adding thread %p to GC list\n", thread);
KSE_LOCK_ACQUIRE(curkse, &_thread_list_lock);
- THR_GCLIST_ADD(thread);
/* Use thread_list_lock */
active_threads--;
#ifdef SYSTEM_SCOPE_ONLY
@@ -1255,8 +1254,12 @@ thr_cleanup(struct kse *curkse, struct pthread *thread)
if (active_threads == 1) {
#endif
KSE_LOCK_RELEASE(curkse, &_thread_list_lock);
+ /* Possible use a signalcontext wrapper to call exit ? */
+ curkse->k_curthread = thread;
+ _tcb_set(curkse->k_kcb, thread->tcb);
exit(0);
}
+ THR_GCLIST_ADD(thread);
KSE_LOCK_RELEASE(curkse, &_thread_list_lock);
if (sys_scope) {
/*
diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c
index f9a17a5..5ed144a 100644
--- a/lib/libpthread/thread/thr_kern.c
+++ b/lib/libpthread/thread/thr_kern.c
@@ -1246,7 +1246,6 @@ thr_cleanup(struct kse *curkse, struct pthread *thread)
KSE_SCHED_UNLOCK(curkse, curkse->k_kseg);
DBG_MSG("Adding thread %p to GC list\n", thread);
KSE_LOCK_ACQUIRE(curkse, &_thread_list_lock);
- THR_GCLIST_ADD(thread);
/* Use thread_list_lock */
active_threads--;
#ifdef SYSTEM_SCOPE_ONLY
@@ -1255,8 +1254,12 @@ thr_cleanup(struct kse *curkse, struct pthread *thread)
if (active_threads == 1) {
#endif
KSE_LOCK_RELEASE(curkse, &_thread_list_lock);
+ /* Possible use a signalcontext wrapper to call exit ? */
+ curkse->k_curthread = thread;
+ _tcb_set(curkse->k_kcb, thread->tcb);
exit(0);
}
+ THR_GCLIST_ADD(thread);
KSE_LOCK_RELEASE(curkse, &_thread_list_lock);
if (sys_scope) {
/*
OpenPOWER on IntegriCloud