Mercurial > cpython-lru_cache-weakref
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 28674:9eb6964b4b6c | 28688:d0ae620afbd4 |
|---|---|
| 151 | 151 |
| 152 long | 152 long |
| 153 PyThread_start_new_thread(void (*func)(void *), void *arg) | 153 PyThread_start_new_thread(void (*func)(void *), void *arg) |
| 154 { | 154 { |
| 155 pthread_t th; | 155 pthread_t th; |
| 156 int success; | 156 int status; |
| 157 sigset_t oldmask, newmask; | 157 sigset_t oldmask, newmask; |
| 158 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) | 158 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) |
| 159 pthread_attr_t attrs; | 159 pthread_attr_t attrs; |
| 160 #endif | 160 #endif |
| 161 dprintf(("PyThread_start_new_thread called\n")); | 161 dprintf(("PyThread_start_new_thread called\n")); |
| 177 * blocked. | 177 * blocked. |
| 178 */ | 178 */ |
| 179 sigfillset(&newmask); | 179 sigfillset(&newmask); |
| 180 SET_THREAD_SIGMASK(SIG_BLOCK, &newmask, &oldmask); | 180 SET_THREAD_SIGMASK(SIG_BLOCK, &newmask, &oldmask); |
| 181 | 181 |
| 182 success = pthread_create(&th, | 182 status = pthread_create(&th, |
| 183 #if defined(PY_PTHREAD_D4) | 183 #if defined(PY_PTHREAD_D4) |
| 184 pthread_attr_default, | 184 pthread_attr_default, |
| 185 (pthread_startroutine_t)func, | 185 (pthread_startroutine_t)func, |
| 186 (pthread_addr_t)arg | 186 (pthread_addr_t)arg |
| 187 #elif defined(PY_PTHREAD_D6) | 187 #elif defined(PY_PTHREAD_D6) |
| 207 SET_THREAD_SIGMASK(SIG_SETMASK, &oldmask, NULL); | 207 SET_THREAD_SIGMASK(SIG_SETMASK, &oldmask, NULL); |
| 208 | 208 |
| 209 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) | 209 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) |
| 210 pthread_attr_destroy(&attrs); | 210 pthread_attr_destroy(&attrs); |
| 211 #endif | 211 #endif |
| 212 if (success == 0) { | 212 if (status != 0) |
| 213 return -1; | |
| 214 | |
| 213 #if defined(PY_PTHREAD_D4) || defined(PY_PTHREAD_D6) || defined(PY_PTHREAD_D7) | 215 #if defined(PY_PTHREAD_D4) || defined(PY_PTHREAD_D6) || defined(PY_PTHREAD_D7) |
| 214 pthread_detach(&th); | 216 pthread_detach(&th); |
| 215 #elif defined(PY_PTHREAD_STD) | 217 #elif defined(PY_PTHREAD_STD) |
| 216 pthread_detach(th); | 218 pthread_detach(th); |
| 217 #endif | 219 #endif |
| 218 } | 220 |
| 219 #if SIZEOF_PTHREAD_T <= SIZEOF_LONG | 221 #if SIZEOF_PTHREAD_T <= SIZEOF_LONG |
| 220 return (long) th; | 222 return (long) th; |
| 221 #else | 223 #else |
| 222 return (long) *(long *) &th; | 224 return (long) *(long *) &th; |
| 223 #endif | 225 #endif |
