On May 17, 3:06 pm, Jean-Paul Calderone <exar...@divmod.comwrote:
On Sat, 17 May 2008 12:49:54 -0700, John Schroeder <jschr...@gmail.comwrote:
On Sat, May 17, 2008 at 12:32 PM, alan <alang...@gmail.comwrote:
This ignores CTRL-C on every platform I've tested:
python -c "import threading; threading.Event().wait()"
^C^C^C^C
It looks to me like all signals are masked before entering wait(). Can
someone familiar with the internals explain and/or justify this
behavior? Thanks,
^C only kills the main thread. Use Control-Break to kill all threads.
Look at that program. It's single-threaded. Where do you think the ^C
is going? :)
Jean-Paul
Look at this program which is also "single-threaded." Clearly,
python's doing something special. I'm hoping someone can tell me what,
and why.
/*
pthreadsig.c
$ gcc pthreadsig.c -lpthread
$ ./a.out
^C
$
*/
#include <pthread.h>
int main(int argc, char** argv) {
int rc = 0;
pthread_mutex_t mtx;
pthread_cond_t cond;
pthread_mutex_init(&mtx, 0);
pthread_cond_init(&cond, 0);
pthread_mutex_lock(&mtx);
rc = pthread_cond_wait(&cond, &mtx);
pthread_mutex_unlock(&mtx);
return rc;
}