signals

When is POSIX thread cancellation not immediate?

淺唱寂寞╮ 提交于 2019-12-21 22:23:54
问题 The POSIX specifies two types for thread cancellation type: PTHREAD_CANCEL_ASYNCHRONOUS , and PTHREAD_CANCEL_DEFERRED (set by pthread_setcanceltype(3) ) determining when pthread_cancel(3) should take effect. By my reading, the POSIX manual pages do not say much about these, but Linux manual page says the following about PTHREAD_CANCEL_ASYNCHRONOUS : The thread can be canceled at any time. (Typically, it will be canceled immediately upon receiving a cancellation request, but the system doesn't

In a SIGILL handler, how can I skip the offending instruction?

对着背影说爱祢 提交于 2019-12-21 20:05:20
问题 I'm going JIT code generation, and I want to insert invalid opcodes into the stream in order to perform some meta-debugging. Everything is fine and good until it hits the instruction, at which point the thing goes into an infinite loop of illegal instruction to signal handler and back. Is there any way I can set the thing to simply skip the bad instruction? 回答1: It's very hacky and UNPORTABLE but: void sighandler (int signo, siginfo_t si, void *data) { ucontext_t *uc = (ucontext_t *)data; int

In a SIGILL handler, how can I skip the offending instruction?

我们两清 提交于 2019-12-21 20:01:06
问题 I'm going JIT code generation, and I want to insert invalid opcodes into the stream in order to perform some meta-debugging. Everything is fine and good until it hits the instruction, at which point the thing goes into an infinite loop of illegal instruction to signal handler and back. Is there any way I can set the thing to simply skip the bad instruction? 回答1: It's very hacky and UNPORTABLE but: void sighandler (int signo, siginfo_t si, void *data) { ucontext_t *uc = (ucontext_t *)data; int

Using long data inside signal handler.

≯℡__Kan透↙ 提交于 2019-12-21 19:55:42
问题 How can I set a variable of type long (on 64 bit machine = 8 bytes) inside a signal handler? I've read that you can only use variables of type sig_atomic_t , which is actually implemented as volatile int inside a signal handler and it is unsafe to modify data types bigger than an int . 回答1: You can use a long inside a signal handler, you can use anything, in fact. The only thing you should take care of is proper synchronization in order to avoid race conditions. sig_atomic_t should be used

Some sort of Ruby “Interrupt”

前提是你 提交于 2019-12-21 18:32:32
问题 So here's what I'm doing -- I have a ruby script that prints out information every minute. I've also set up a proc for a trap so that when the user hits ctrl-c, the process aborts. The code looks something like this: switch = true Signal.trap("SIGINT") do switch = false end lastTime = Time.now while switch do if Time.now.min > lastTime.min then puts "A minute has gone by!" end end Now the code itself is valid and runs well, but it does a lot of useless work checking the value of switch as

Performance of signals in Django

ぐ巨炮叔叔 提交于 2019-12-21 17:38:11
问题 I have created a few post_save signals but I was wondering if there will be performance issues later on. For example, I have something like this: def my_signal(sender, **kwargs): # some minimal processing posts = len(MyPosts.objects.filter(date__gte=variable)) if entries == "20": # crate an object and assign it to the post's author. post_save.connect(my_signal, sender=MyPosts) Let's say I have a very busy site and this is firing each time a post is created. Is it too bad to performance?. Is

Wait for signal, then continue execution

感情迁移 提交于 2019-12-21 17:37:51
问题 I am trying to make a program that suspends its execution until a signal arrives . Then, after the signal arrives I just want my code to continue its execution from where it was . I don't want it to execute a function handler or whatsoever. Is there a simple way of doing this? I have been struggling for a week or so, reading here and there, and didn't manage to get a fully operative code. In particular, I want the main program to create a thread that waits for some particular event to happen

posix threads block signal and unblock

牧云@^-^@ 提交于 2019-12-21 12:40:04
问题 Is there a way to block certain signals and unblock other signals in the same set? I just dont seem to get my head around it! An example sigset_t set; sigemptyset(&set); sigaddset(&set, SIGUSR1); // Block signal SIGUSR1 in this thread pthread_sigmask(SIG_BLOCK, &set, NULL); sigaddset(&set, SIGALRM); // Listen to signal SIGUSR2 pthread_sigmask(SIG_UNBLOCK, &set, NULL); pthread_t printer_thread1, printer_thread2; pthread_create(&printer_thread1, NULL, print, (void *)&f1); pthread_create(

Android _Unwind_Backtrace inside sigaction

安稳与你 提交于 2019-12-21 12:11:02
问题 I am trying to catch signals such as SIGSEGV in my Android NDK app for debugging purpose. For that, I have set up a sigaction that is called. I am now trying to get the stack of the call. The problem is that _Unwind_Backtrace only works on current stack and sigaction runs inside its own stack. So, is there a way to get the stack of the execution pointer that received the signal? (Basically tell _Unwind_Backtrace to unwind another stack than the current?) I should point out that : Using

How to pass data from a QDialog?

安稳与你 提交于 2019-12-21 11:29:57
问题 In Qt, what is the most elegant way to pass data from a QDialog subclass to the component that started the dialog in the cases where you need to pass down something more complex than a boolean or an integer return code? I'm thinking emit a custom signal from the accept() slot but is there something else? 回答1: QDialog has its own message loop and since it stops your application workflow, I usually use the following scheme: MyQDialog dialog(this); dialog.setFoo("blah blah blah"); if(dialog.exec