signals

Signal handling using “TERM”

非 Y 不嫁゛ 提交于 2019-11-27 01:37:03
I have a standalone application in which I have to prompt the user with an confirm dialog box to save the changes made by him when he tries to shutdown the system by start-->shutdown . I came to know that by using signalhandlers we can do it. Can some one help me how to use signal handlers VonC Update May 2012 (2 and half years later) Trejkaz comments: On current versions of Java this signal handling code fails because the " INT " signal is "reserved by the VM or the OS". Additionally, none of the other valid signal names actually fire when something requests the application to close (I just

Getting the saved instruction pointer address from a signal handler

风格不统一 提交于 2019-11-27 00:57:49
问题 My question is somewhat different from others that have asked about fault addresses. I'm trying to implement a horrible hack to determine, from a signal handler, whether the signal interrupted a syscall or ordinary user code by inspecting the code at the saved instruction pointer and comparing it against the possible syscall entry instructions for the host architecture it's running on. This is part of implementing correct POSIX thread cancellation that does not suffer from the race condition

Is Django post_save signal asynchronous?

我的梦境 提交于 2019-11-27 00:21:32
问题 I have a 'like' function which is just like social networks like or thumbs up function; the user clicks the star / heart / whatever to mark the content as liked. It is done with ajax and must be fast. The only problem here is that for some reasons I have to do some tasks for each 'like' and I found out they were coded straight in the 'like' view and it makes it slow. I am thinking of using signals to make the execution of these tasks asynchronous so the view can send back the json right away

Providing/passing argument to signal handler

三世轮回 提交于 2019-11-27 00:20:18
问题 Can I provide/pass any arguments to signal handler? /* Signal handling */ struct sigaction act; act.sa_handler = signal_handler; /* some more settings */ Now, handler looks like this: void signal_handler(int signo) { /* some code */ } If I want to do something special i.e. delete temp files, can I provide those files as an argument to this handler? Edit 0: Thanks for the answers. We generally avoid/discourage use of global variables. And in this case, If you have a huge program, things can go

Where are core dumps written on Mac?

坚强是说给别人听的谎言 提交于 2019-11-27 00:00:32
问题 On Mac OS X, if I send SIGQUIT to my C program, it terminates, but there is no core dump file. Do you have to manually enable core dumps on Mac OS X (how?), or are they written to somewhere else instead of the working directory? 回答1: It seems they are suppressed by default. Running $ ulimit -c unlimited Will enable core dumps for the current terminal, and it will be placed in /cores as core.PID . When you open a new session, it will be set to the default value again. 回答2: On macOS, your crash

Why does PySide implicitely create object members from class members for Signals?

与世无争的帅哥 提交于 2019-11-26 23:37:22
问题 On the PySide signals and slots page it says: "Signals are runtime objects owned by instances, they are not class attributes". Apparently the QObject constructor looks in the class attributes for Signals and copies them to the object instance. This is confirmed by my test program. from PySide import QtCore class Klass(QtCore.QObject): lst = [] sig = QtCore.Signal(str) def main(): obj1 = Klass() obj2 = Klass() print "id: obj1.lst = {}, obj1.sig = {}".format(id(obj1.lst), id(obj1.sig)) print

How to get fullstacktrace using _Unwind_Backtrace on SIGSEGV

旧街凉风 提交于 2019-11-26 23:20:30
问题 I handle SIGSEGV by code: int C() { int *i = NULL; *i = 10; // Crash there } int B() { return C(); } int A() { return B(); } int main(void) { struct sigaction handler; memset(&handler,0,sizeof(handler)); handler.sa_sigaction = handler_func; handler.sa_flags = SA_SIGINFO; sigaction(SIGSEGV,&handler,NULL); return(C()); } Where handler code are: static int handler_func(int signal, siginfo_t info, void* rserved) { const void* stack[MAX_DEPTH]; StackCrowlState state; state.addr = stack; state

Problem in Timers and signal

夙愿已清 提交于 2019-11-26 23:11:35
问题 I have implemented a POSIX timer using timer_create( ) API, and this will generate SIGUSR1 when the timer expires for which i have put a handler code. Now the problem is, if this program receives another SIGUSR1, then the same signal handler will be invoked and caught. Is there any way to prevent this, so that the handler can catch signals only generated by the timer? 回答1: Will this work for you? (Modified the code from example in timer_create man page.) #include <stdlib.h> #include <unistd.h

python: windows equivalent of SIGALRM

江枫思渺然 提交于 2019-11-26 23:11:31
I have this decorator: def timed_out(timeout): def decorate(f): if not hasattr(signal, "SIGALRM"): return f def handler(signum, frame): raise TimedOutExc() @functools.wraps(f) def new_f(*args, **kwargs): old = signal.signal(signal.SIGALRM, handler) signal.alarm(timeout) try: result = f(*args, **kwargs) finally: signal.signal(signal.SIGALRM, old) signal.alarm(0) return result new_f.func_name = f.func_name return new_f return decorate The code only does anything on linux, though, as on windows, there is no SIGALRM . What would be the simplest way to have this code work in Windows as well? It's

Why can't I ignore SIGSEGV signal?

旧时模样 提交于 2019-11-26 23:02:23
问题 Here is my code, #include<signal.h> #include<stdio.h> int main(int argc,char ** argv) { char *p=NULL; signal(SIGSEGV,SIG_IGN); //Ignoring the Signal printf("%d",*p); printf("Stack Overflow"); //This has to be printed. Right? return 0; } While executing the code, i'm getting segmentation fault. I ignored the signal using SIG_IGN. So I shouldn't get Segmentation fault. Right? Then, the printf() statement after printing '*p' value must executed too. Right? 回答1: Your code is ignoring SIGSEGV