diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2003-04-19 07:44:52 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2003-04-19 07:44:52 (GMT) |
commit | 910ae6283a2e715bd13962bd8e4da71c4fd3627d (patch) | |
tree | 2a23cfce7b1bc88ccc6bf1f2a12bece82a61ec09 /Python/thread_pthread.h | |
parent | 1e91d8eb030656386ef3a07e8a516683bea85610 (diff) | |
download | cpython-910ae6283a2e715bd13962bd8e4da71c4fd3627d.zip cpython-910ae6283a2e715bd13962bd8e4da71c4fd3627d.tar.gz cpython-910ae6283a2e715bd13962bd8e4da71c4fd3627d.tar.bz2 |
Patch #716969: Detect thread creation failure. Will backport to 2.2.
Diffstat (limited to 'Python/thread_pthread.h')
-rw-r--r-- | Python/thread_pthread.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h index 2596af5..2e594fe 100644 --- a/Python/thread_pthread.h +++ b/Python/thread_pthread.h @@ -188,7 +188,7 @@ long PyThread_start_new_thread(void (*func)(void *), void *arg) { pthread_t th; - int success; + int status; sigset_t oldmask, newmask; #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) pthread_attr_t attrs; @@ -214,7 +214,7 @@ PyThread_start_new_thread(void (*func)(void *), void *arg) sigfillset(&newmask); SET_THREAD_SIGMASK(SIG_BLOCK, &newmask, &oldmask); - success = pthread_create(&th, + status = pthread_create(&th, #if defined(PY_PTHREAD_D4) pthread_attr_default, (pthread_startroutine_t)func, @@ -244,13 +244,15 @@ PyThread_start_new_thread(void (*func)(void *), void *arg) #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) pthread_attr_destroy(&attrs); #endif - if (success == 0) { + if (status != 0) + return -1; + #if defined(PY_PTHREAD_D4) || defined(PY_PTHREAD_D6) || defined(PY_PTHREAD_D7) - pthread_detach(&th); + pthread_detach(&th); #elif defined(PY_PTHREAD_STD) - pthread_detach(th); + pthread_detach(th); #endif - } + #if SIZEOF_PTHREAD_T <= SIZEOF_LONG return (long) th; #else |