Mercurial > cpython-lru_cache-weakref
diff Python/thread_pthread.h @ 28688:d0ae620afbd4 2.2
Patch #716969: Detect thread creation failure.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Sat, 19 Apr 2003 07:46:28 +0000 |
| parents | 9eb6964b4b6c |
| children |
line wrap: on
line diff
--- a/Python/thread_pthread.h Fri Apr 18 11:21:22 2003 +0000 +++ b/Python/thread_pthread.h Sat Apr 19 07:46:28 2003 +0000 @@ -153,7 +153,7 @@ 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; @@ -179,7 +179,7 @@ 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, @@ -209,13 +209,15 @@ #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
