From 472022708ee08ac559dde540891eb2f8c2a9afcf Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 14 Feb 2003 23:31:11 +0000 Subject: Update. 2003-02-14 Ulrich Drepper * sysdeps/generic/libc-start.c [HAVE_PTR_NTHREADS]: Decrement thread counter and only call __exit_thread if this is not the last thread. --- nptl/pthread_create.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'nptl/pthread_create.c') diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 2b33243cee..c96a2813e5 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -44,6 +44,9 @@ static td_thr_events_t __nptl_threads_events; /* Pointer to descriptor with the last event. */ static struct pthread *__nptl_last_event; +/* Number of threads running. */ +unsigned int __nptl_nthreads = 1; + /* Code to allocate and deallocate a stack. */ #define DEFINE_DEALLOC @@ -197,6 +200,9 @@ __free_tcb (struct pthread *pd) static int start_thread (void *arg) { + /* One more thread. */ + atomic_increment (&__nptl_nthreads); + struct pthread *pd = (struct pthread *) arg; #if HP_TIMING_AVAIL @@ -215,6 +221,14 @@ start_thread (void *arg) } + /* If this is the last thread we terminate the process now. We + do not notify the debugger, it might just irritate it if there + is no thread left. */ + if (atomic_decrement_and_test (&__nptl_nthreads)) + /* This was the last thread. */ + exit (0); + + /* Report the death of the thread if this is wanted. */ if (__builtin_expect (pd->report_events, 0)) { -- cgit 1.4.1