*** Python-2.1/Python/thread_pthread.h.orig Fri Oct 5 11:23:39 2001 --- Python-2.1/Python/thread_pthread.h Fri Oct 5 11:23:47 2001 *************** *** 4,9 **** --- 4,10 ---- #include #include #include + #include /* try to determine what version of the Pthread Standard is installed. *************** *** 62,67 **** --- 63,80 ---- #endif + /* On platforms that don't use standard POSIX threads pthread_sigmask() + * isn't present. DEC threads uses sigprocmask() instead as do most + * other UNIX International compliant systems that don't have the full + * pthread implementation. + */ + #ifdef PY_PTHREAD_STD + # define SET_THREAD_SIGMASK pthread_sigmask + #else + # define SET_THREAD_SIGMASK sigprocmask + #endif + + /* A pthread mutex isn't sufficient to model the Python lock type * because, according to Draft 5 of the docs (P1003.4a/D5), both of the * following are undefined: *************** *** 128,137 **** --- 141,158 ---- { pthread_t th; int success; + sigset_t oldmask, newmask; dprintf(("PyThread_start_new_thread called\n")); if (!initialized) PyThread_init_thread(); + /* Mask all signals in the current thread before creating the new + * thread. This causes the new thread to start with all signals + * blocked. + */ + sigfillset(&newmask); + SET_THREAD_SIGMASK(SIG_BLOCK, &newmask, &oldmask); + success = pthread_create(&th, #if defined(PY_PTHREAD_D4) pthread_attr_default, *************** *** 152,157 **** --- 173,181 ---- #endif ); + /* Restore signal mask for original thread */ + SET_THREAD_SIGMASK(SIG_SETMASK, &oldmask, NULL); + if (success == 0) { #if defined(PY_PTHREAD_D4) || defined(PY_PTHREAD_D6) || defined(PY_PTHREAD_D7) pthread_detach(&th);