473,395 Members | 2,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 908
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Douwe | last post by:
I'm trying to write a piece of C code that has two threads: The first thread waits for a socket connection. The second thread is in a continues cycle waiting for an period of time (lets say 500 ms)...
6
by: jose luis fernandez diaz | last post by:
Hi, I have a C program running in background in UNIX. From a shell script I want to notify it some events. The easiest way to do it is through signals, but it is not correct because signal are...
0
by: Arnaud Debaene | last post by:
Hello all. I've got a bunch of existing, non managed, C++ DLLs that export types with, among other things, public events implemented using the boost::signals library. Now, I need to have...
3
by: alan | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.