Mercurial > cpython-lru_cache-weakref
diff Python/thread.c @ 1047:6b5a34db21fe legacy-trunk
Added C++ support in thread.h; don't use signals if not strictly
necessary, and when they are, use SIGKILL; when compiled with -DDEBUG,
only print debug messages when "THREADDEBUG" is set in the environment.
| author | Sjoerd Mullender <sjoerd@acm.org> |
|---|---|
| date | Fri, 11 Sep 1992 15:19:27 +0000 |
| parents | b33228e3c2c2 |
| children | 9ae65ee09735 |
line wrap: on
line diff
--- a/Python/thread.c Tue Sep 08 21:20:12 1992 +0000 +++ b/Python/thread.c Fri Sep 11 15:19:27 1992 +0000 @@ -1,7 +1,8 @@ #include "thread.h" #ifdef DEBUG -#define dprintf(args) printf args +static int thread_debug = 0; +#define dprintf(args) (thread_debug && printf args) #else #define dprintf(args) #endif @@ -102,6 +103,9 @@ struct sigaction s; #endif +#ifdef DEBUG + thread_debug = getenv("THREADDEBUG") != 0; +#endif dprintf(("init_thread called\n")); if (initialized) return; @@ -112,7 +116,7 @@ atexit(maybe_exit); s.sa_handler = exit_sig; sigemptyset(&s.sa_mask); - sigaddset(&s.sa_mask, SIGUSR1); + /*sigaddset(&s.sa_mask, SIGUSR1);*/ s.sa_flags = 0; sigaction(SIGUSR1, &s, 0); prctl(PR_SETEXITSIG, SIGUSR1); @@ -189,8 +193,12 @@ int i; /* notify other threads */ - for (i = 0; i < maxpidindex; i++) - (void) kill(pidlist[i], SIGUSR1); + if (nthreads >= 0) { + dprintf(("kill other threads\n")); + for (i = 0; i < maxpidindex; i++) + (void) kill(pidlist[i], SIGKILL); + _exit(exit_status); + } } waiting_for_threads = 1; ussetlock(wait_lock); @@ -212,7 +220,8 @@ if (waiting_for_threads) { dprintf(("main thread is waiting\n")); usunsetlock(wait_lock); - } + } else if (do_exit) + (void) kill(my_pid, SIGUSR1); (void) usunsetlock(count_lock); _exit(0); #endif @@ -361,6 +370,8 @@ #endif dprintf(("allocate_sema called\n")); + if (!initialized) + init_thread(); #ifdef __sgi sema = usnewsema(shared_arena, value);
