signals

python timer mystery

梦想与她 提交于 2019-12-01 15:20:39
问题 Well, at least a mystery to me. Consider the following: import time import signal def catcher(signum, _): print "beat!" signal.signal(signal.SIGALRM, catcher) signal.setitimer(signal.ITIMER_REAL, 2, 2) while True: time.sleep(5) Works as expected i.e. delivers a "beat!" message every 2 seconds. Next, no output is produced: import time import signal def catcher(signum, _): print "beat!" signal.signal(signal.SIGVTALRM, catcher) signal.setitimer(signal.ITIMER_VIRTUAL, 2, 2) while True: time.sleep

C linkage for function pointer passed to C library

谁说胖子不能爱 提交于 2019-12-01 15:13:39
问题 My case is pretty simple: I want my C++ program to deal with Unix signals. To do so, glibc provides a function in signal.h called sigaction , which expects to receive a function pointer as its second argument. extern "C" { void uponSignal(int); } void uponSignal(int) { // set some flag to quit the program } static void installSignalHandler() { // initialize the signal handler static struct sigaction sighandler; memset( &sighandler, 0, sizeof(struct sigaction) ); sighandler.sa_handler =

unit testing for CTRL-C sent to an application

删除回忆录丶 提交于 2019-12-01 14:48:18
问题 I am developing an application handling CTRL-C. I am producing a signal handler to shut-down gracefully threads and other resources. I want to test CTRL-C in different scenarios where my application might be. I know how to setup those for the process under test, but I need a way ( in the code of the running test suite ) to check whether that condition is reached or not to call exactly CTRL-C. I work in Linux and I want to run my tests automatically with the help of CPPUNIT . In each of my

Floating Point Exception Core Dump

故事扮演 提交于 2019-12-01 14:35:46
问题 I am newbie on the Linux signals, please help. The following code get core dump when run in Linux 2.6 gcc. $ ./a.out Floating point exception (core dumped) The questions: 1. Since a process signal mask is installed, shouldn't the "SIGFPGE" generated by line 40 volatile int z = x/y; be blocked? 2. If it is not blocked, since a signal handler has been installed, shouldn't the "SIGFPE" be captured by the signal handler, instead of a core dump? 3. If I commented out line 40 volatile int z = x/y;

Fatal signal 16 (SIGSTKFLT) has been occured unexpectedly

坚强是说给别人听的谎言 提交于 2019-12-01 14:29:57
Today I faced with a strange issue. I installed my application on three devices Asus Transformer Pad Infinity TF700T Samsung I9082 Galaxy Grand Duos LG Optimus L7 II Dual p715 First, I ran my app from Eclipse in the Debug mode with all of these devices. And it's ok. Then, I ran my app in usual way (right on devices). And in this way all my bad have been started. For 1 and 2 devices all ok. But 3 device didn't work as I expected. The LogCat showed me the following fatal error: 01-14 01:36:47.529: E/dalvikvm(11294): threadid=1: stuck on threadid=14, giving up 01-14 01:36:47.529: A/libc(11294):

PyQt and QSignalMapper/lambdas - multiple signals, single slot

浪尽此生 提交于 2019-12-01 14:11:48
I have a list of actions on a menu in PyQt, one for each different feed I want to display. So I have a Y that sets the active feed to Y, Z sets it to Z, etc. (For a webcomic reading program). I have each on the menu, and felt that an automated approach might be better; rather than typing out each time. Something like a function that adds it to a dictionary, then connects it up with a signal for each to a single slot. However, I want that slot function, say it's called Foo, to take a parameter to decide what has been clicked. So if X was clicked, then X, Y passes Y, etc. Looked around, and one

Is SIGSEGV special when generated by `kill`?

*爱你&永不变心* 提交于 2019-12-01 12:43:46
I know that SIGSEGV can't be ignored when the kernel uses it to report a memory access violation. But if I install a signal handler for SIGSEGV that does nothing, and then another process uses kill to send me that signal, will this behave the same as if I had used a "normal" signal (like SIGUSR1 ) instead? Grijesh Chauhan I have function that receive signal SIGSEGV but do nothing with it, does it mean that signal is ignored ? Yes, you caught the signal SIGSEGV and do nothing in handler, control returns. In general ignoring real SIGSEGV doesn't mean the error won't enable the program to

Fatal signal 16 (SIGSTKFLT) has been occured unexpectedly

末鹿安然 提交于 2019-12-01 12:37:42
问题 Today I faced with a strange issue. I installed my application on three devices Asus Transformer Pad Infinity TF700T Samsung I9082 Galaxy Grand Duos LG Optimus L7 II Dual p715 First, I ran my app from Eclipse in the Debug mode with all of these devices. And it's ok. Then, I ran my app in usual way (right on devices). And in this way all my bad have been started. For 1 and 2 devices all ok. But 3 device didn't work as I expected. The LogCat showed me the following fatal error: 01-14 01:36:47

PyQt and QSignalMapper/lambdas - multiple signals, single slot

≡放荡痞女 提交于 2019-12-01 10:42:06
问题 I have a list of actions on a menu in PyQt, one for each different feed I want to display. So I have a Y that sets the active feed to Y, Z sets it to Z, etc. (For a webcomic reading program). I have each on the menu, and felt that an automated approach might be better; rather than typing out each time. Something like a function that adds it to a dictionary, then connects it up with a signal for each to a single slot. However, I want that slot function, say it's called Foo, to take a parameter

Is SIGSEGV special when generated by `kill`?

孤人 提交于 2019-12-01 10:16:12
问题 I know that SIGSEGV can't be ignored when the kernel uses it to report a memory access violation. But if I install a signal handler for SIGSEGV that does nothing, and then another process uses kill to send me that signal, will this behave the same as if I had used a "normal" signal (like SIGUSR1 ) instead? 回答1: I have function that receive signal SIGSEGV but do nothing with it, does it mean that signal is ignored ? Yes, you caught the signal SIGSEGV and do nothing in handler, control returns.