471,108 Members | 1,334 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,108 software developers and data experts.

Re: waiting on an event blocks all signals

On Sat, 17 May 2008 12:49:54 -0700, John Schroeder <js******@gmail.comwrote:
>On Sat, May 17, 2008 at 12:32 PM, alan <al******@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
Jun 27 '08 #1
1 844
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;
}
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.