signals

PyQt proper use of emit() and pyqtSignal()

五迷三道 提交于 2019-11-27 10:48:48
问题 I am reading through some documentation on PyQt5 to come up with a simple signal-slot mechanism. I have come to a halt due to a design consideration. Consider the following code: import sys from PyQt5.QtCore import (Qt, pyqtSignal) from PyQt5.QtWidgets import (QWidget, QLCDNumber, QSlider, QVBoxLayout, QApplication) class Example(QWidget): def __init__(self): super().__init__() self.initUI() def printLabel(self, str): print(str) def logLabel(self, str): '''log to a file''' pass def initUI

Does linux allow any system call to be made from signal handlers?

二次信任 提交于 2019-11-27 09:13:20
My understanding is that, in general, the behavior is undefined if you call a non-async signal safe function from a signal handler, but I've heard that linux allows you to call any system call safely. Is this true? Also, the only portable behavior for a SIGSEGV handler is to abort or exit, but I understand linux will actually resume execution if you return, true? Basile Starynkevitch I would believe that any real system call can be called from a signal handler. A true syscall has a number in <asm/unistd.h> (or <asm/unistd_64.h> ). some posix functions from section 2 of man pages are

Why doesn't my signal handler (which throws an exception) trigger more than once?

喜欢而已 提交于 2019-11-27 08:23:22
问题 I am trying to set up an exception handler using sigaction. It works well for the first exception. But the sigaction handler is not called after the 1st exception and the program ends abruptly when the second signal happens. #include <iostream> #include <signal.h> #include <exception> #include <string.h> typedef void (*SigactionHandlerPointer)(int iSignal, siginfo_t * psSiginfo, void * psContext); using namespace std; void SigactionHookHandler( int iSignal, siginfo_t * psSiginfo, void *

How do I configure ruby to enter the debugger on Ctrl-C (SIGINT)?

时间秒杀一切 提交于 2019-11-27 08:09:31
问题 I'd like to enter the debugger upon typing ctrl-C (or sending a SIGINT). I have installed the debugger (I'm running Ruby 1.9.3) and verified that it works. I've added this to my setup files (this is for Padrino, but I assume it would be similar for Rails): # file: config/boot.rb Padrino.before_load do trap("SIGINT") { debugger } if Padrino.env == :development end ... but typing Ctrl-C does not invoke the debugger. In fact, if I replace debugger with puts "saw an interrupt!" , typing Ctrl-C

Signals received by bash when terminal is closed

旧街凉风 提交于 2019-11-27 08:07:29
Use trap to capture signals like this: i=-1;while((++i<33)); do trap "echo $i >> log.txt" $i; done And close the terminal by force. The content in log.txt is then (under redhat linux): 1 18 1 17 0 Where these signals from? The first signal is SIGHUP; that gets sent to all processes in the process group when the terminal disconnects (hangs up - hence HUP). The second signal is SIGCONT (thanks, SiegeX, for the numbers). This is slightly surprising; it suggests you had a job stopped in the background which had to be allowed to run again. The third signal is another SIGHUP. This was likely sent to

Understanding scipy deconvolve

北城以北 提交于 2019-11-27 08:05:18
I'm trying to understand scipy.signal.deconvolve . From the mathematical point of view a convolution is just the multiplication in fourier space so I would expect that for two functions f and g : Deconvolve(Convolve(f,g) , g) == f In numpy/scipy this is either not the case or I'm missing an important point. Although there are some questions related to deconvolve on SO already (like here and here ) they do not address this point, others remain unclear ( this ) or unanswered ( here ). There are also two questions on SignalProcessing SE ( this and this ) the answers to which are not helpful in

Signal handling in C - interrupt in interrupt

一个人想着一个人 提交于 2019-11-27 07:52:35
问题 I was wondering if it is possible to be interrupted by a signal when my program is handling other signal at the same time, I tried to simulate it with: #include<signal.h> #include<stdlib.h> #include<stdio.h> #include<unistd.h> #include<sys/wait.h> #include<string.h> void sig_output() { sigset_t set; sigprocmask(0,NULL,&set); printf("currently blocking:"); if (sigismember(&set,SIGUSR1)) printf("\nSIGUSR1"); if(sigismember(&set,SIGUSR2)) printf("\nSIGUSR2"); printf("\n"); return ; } void sig

Why no output on console on signal handling?

大兔子大兔子 提交于 2019-11-27 07:51:06
问题 I was trying this program from Advance Programming in Unix Environment. #include<stdio.h> #include<signal.h> static void handler(int sig){ if(sig == SIGUSR1) printf("handled user1 signal"); else if(sig == SIGUSR2) printf("handles user2 signal"); else printf("unkown signal"); } int main(){ if(signal(SIGUSR1, handler) == SIG_ERR) printf("can't handle signal SIGUSR1"); if(signal(SIGUSR2, handler) == SIG_ERR) printf("can't handle signal SIGUSR2"); for(;;) pause(); return 0; } I am using Ubuntu 11

Throwing an exception from within a signal handler

99封情书 提交于 2019-11-27 07:50:56
We have a library that deals with many aspects of error reporting. I have been tasked to port this library to Linux. When running though my little test suite, one of the tests failed. A simplified version of the test appears below. // Compiler: 4.1.1 20070105 RedHat 4.1.1-52 // Output: Terminate called after throwing an instance of 'int' abort #include <iostream> #include <csignal> using namespace std; void catch_signal(int signalNumber) { signal(SIGINT, SIG_DFL); throw(signalNumber); } int test_signal() { signal(SIGINT, catch_signal); try { raise(SIGINT); } catch (int &z) { cerr << "Caught

Running startup code right after Django settings? (also for commands)

混江龙づ霸主 提交于 2019-11-27 07:48:03
问题 I am using mongoengine and would like to run connect() after settings (not inside them as suggested in its docs). This is actually more like a general question how to run code right after all settings are loaded. Update: I need a solution for management commands as well. Common approach is adding a middleware with exception MiddlewareNotUsed or adding code to root urls.py, but both don't work for commands. 回答1: The normal place for startup-like code is in a urls.py (when you need the settings