Mercurial > cpython-lru_cache-weakref
comparison Python/thread_pthread.h @ 28687:40d287c3d906 legacy-trunk
Patch #716969: Detect thread creation failure. Will backport to 2.2.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Sat, 19 Apr 2003 07:44:52 +0000 |
| parents | c1ba50790c83 |
| children | a408ac5527c3 |
comparison
equal
deleted
inserted
replaced
| 28686:70d6f8b0fc69 | 28687:40d287c3d906 |
|---|---|
| 186 | 186 |
| 187 long | 187 long |
| 188 PyThread_start_new_thread(void (*func)(void *), void *arg) | 188 PyThread_start_new_thread(void (*func)(void *), void *arg) |
| 189 { | 189 { |
| 190 pthread_t th; | 190 pthread_t th; |
| 191 int success; | 191 int status; |
| 192 sigset_t oldmask, newmask; | 192 sigset_t oldmask, newmask; |
| 193 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) | 193 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) |
| 194 pthread_attr_t attrs; | 194 pthread_attr_t attrs; |
| 195 #endif | 195 #endif |
| 196 dprintf(("PyThread_start_new_thread called\n")); | 196 dprintf(("PyThread_start_new_thread called\n")); |
| 212 * blocked. | 212 * blocked. |
| 213 */ | 213 */ |
| 214 sigfillset(&newmask); | 214 sigfillset(&newmask); |
| 215 SET_THREAD_SIGMASK(SIG_BLOCK, &newmask, &oldmask); | 215 SET_THREAD_SIGMASK(SIG_BLOCK, &newmask, &oldmask); |
| 216 | 216 |
| 217 success = pthread_create(&th, | 217 status = pthread_create(&th, |
| 218 #if defined(PY_PTHREAD_D4) | 218 #if defined(PY_PTHREAD_D4) |
| 219 pthread_attr_default, | 219 pthread_attr_default, |
| 220 (pthread_startroutine_t)func, | 220 (pthread_startroutine_t)func, |
| 221 (pthread_addr_t)arg | 221 (pthread_addr_t)arg |
| 222 #elif defined(PY_PTHREAD_D6) | 222 #elif defined(PY_PTHREAD_D6) |
| 242 SET_THREAD_SIGMASK(SIG_SETMASK, &oldmask, NULL); | 242 SET_THREAD_SIGMASK(SIG_SETMASK, &oldmask, NULL); |
| 243 | 243 |
| 244 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) | 244 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) |
| 245 pthread_attr_destroy(&attrs); | 245 pthread_attr_destroy(&attrs); |
| 246 #endif | 246 #endif |
| 247 if (success == 0) { | 247 if (status != 0) |
| 248 return -1; | |
| 249 | |
| 248 #if defined(PY_PTHREAD_D4) || defined(PY_PTHREAD_D6) || defined(PY_PTHREAD_D7) | 250 #if defined(PY_PTHREAD_D4) || defined(PY_PTHREAD_D6) || defined(PY_PTHREAD_D7) |
| 249 pthread_detach(&th); | 251 pthread_detach(&th); |
| 250 #elif defined(PY_PTHREAD_STD) | 252 #elif defined(PY_PTHREAD_STD) |
| 251 pthread_detach(th); | 253 pthread_detach(th); |
| 252 #endif | 254 #endif |
| 253 } | 255 |
| 254 #if SIZEOF_PTHREAD_T <= SIZEOF_LONG | 256 #if SIZEOF_PTHREAD_T <= SIZEOF_LONG |
| 255 return (long) th; | 257 return (long) th; |
| 256 #else | 258 #else |
| 257 return (long) *(long *) &th; | 259 return (long) *(long *) &th; |
| 258 #endif | 260 #endif |
