signals

How do I trigger the default signal handling behavior?

南楼画角 提交于 2019-12-07 08:07:32
问题 In my Java application I want to capture SIGINTs, do some pre-processing, and then let the default behavior (process termination) run. I would think I could do something like this: Signal.handle(new Signal("INT"), new SignalHandler() { @Override public void handle(Signal signal) { // preprocessing // ... // now do default behavior SignalHandler.SIG_DFL.handle(signal); } }); However when I send at SIGINT to this application, I get a SEGV : # # A fatal error has been detected by the Java

Temporarily block signals between two QObjects

点点圈 提交于 2019-12-07 05:43:51
问题 I would like to generically and temporarily block the signals between two QObjects without modifying the other signals/slots behavior, and without knowing their contexts. Something like QObject::blockSignals(bool), but only acting between two QObjects . That is, implementing the following SignalBlocker::blockSignals(bool) function: class SignalBlocker { public: SignalBlocker(QObject *sender, QObject *receiver) : mSender(sender), mReceiver(receiver) {} void blockSignals(bool block); private:

What's the proper way to construct a signal/slot wrapper to a blocking call?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 05:33:24
Suppose I have a QObject and a blocking method (say, it's a library call that needs to fetch a lot of data from the network before returning). class Foo : public QObject { Bar* _bar; public: // non blocking call, emits stuffDone when done void startStuff(int a, int b); signals: void stuffDone(int sum); } class Bar { public: // Blocking call int doStuff(int a, b) { for(int i=0; i<=100000000000; i++); return a + b; } } I'd like my Foo::startStuff method to run doStuff in the appropriate (separate) thread and trigger a stuffDone signal upon completion. startStuff would have to return immediately.

How to send signal using callback called from external script?

送分小仙女□ 提交于 2019-12-07 04:15:24
Introduction I'm trying to update QT GUI element basing on the state of calculations in embedded python script. I'm able to extract required values from python, but can't set a reference to c++ object to make it work. The details Let's assume python code is called (in calc.cpp) this way: void class_name::transfer(varA, varB, varC) { Py_Initialize(); emit inprogress(70); //HERE IT WORKS object module = import("__main__"); object name_space = module.attr("__dict__"); exec_file("MyModule.py", name_space, name_space); object MyFunc = name_space["MyFunc"]; object result = MyFunc(varA, varB, varC,

signal.alarm not triggering exception on time

孤街醉人 提交于 2019-12-07 04:08:18
问题 I've slightly modified the signal example from the official docs (bottom of page). I'm calling sleep 10 but I would like an alarm to be raised after 1 second. When I run the following snippet it takes way more than 1 second to trigger the exception (I think it runs the full 10 seconds). import signal, os def handler(signum, frame): print 'Interrupted', signum raise IOError("Should after 1 second") signal.signal(signal.SIGALRM, handler) signal.alarm(1) os.system('sleep 10') signal.alarm(0) How

How do I recover from EXC_BAD_ACCESS?

£可爱£侵袭症+ 提交于 2019-12-07 03:54:14
问题 I'm intentionally causing an EXC_BAD_ACCESS . By triggering a write to an NSObject in a read-only virtual memory page. Ideally, I'd like to catch EXC_BAD_ACCESS , mark the virtual memory page as read-write and have execution continue as it normally would have. Is this even possible? The code I've written to cause the EXC_BAD_ACCESS is below. WeakTargetObject.h (ARC) @interface WeakTargetObject : NSObject @property (nonatomic, weak) NSObject *target; @end WeakTargetObject.m (ARC)

addHow to make django post_save signal run only during creation

六月ゝ 毕业季﹏ 提交于 2019-12-07 02:11:42
问题 I'm using django-notifications in my project and I want to notify a particular user whenever a model is created using the signal, but the post_save also runs when a model is being updated how do I prevent this and only make the post_save method run when a model is created. models.py class Card(models.Model): user = models.ForeignKey(User,on_delete=models.CASCADE) title = models.CharField(max_length=100) description = models.TextField(blank=True) list = models.ForeignKey(List, related_name=

Forwarding SIGTERM over ssh

一个人想着一个人 提交于 2019-12-06 22:10:11
问题 I want ssh to forward the SIGTERM signal to the remote command. ssh root@localhost /root/print-signal.py Get PID of ssh: ps aux| grep print-signal Kill the matching ssh process: kill pid-of-ssh Unfortunately only the ssh process itself gets the signal, not the remote command ( print-signal.py ). The remote command does not terminate :-( How can I make ssh "forward" the SIGTERM signal to the remote command? 回答1: I think you can do the following : ssh root@localhost /root/print-signal.py **Get

When did HUP stop getting sent and what can I do about it?

江枫思渺然 提交于 2019-12-06 21:52:15
问题 Back in the day when I was young and Unix was the new thing, creating a process that did not get killed when you logged out was a challenge. We used the nohup command to protect our persistent processes from the HUP signal. If we weren't careful, our processes would get killed when we logged off, or even closed the shell we started them from. Fast forward to today and I find I am surprised that the default appears to be exactly the opposite. On both Ubuntu and Red Hat systems I find that I

SDL/C++ OpenGL Program, how do I stop SDL from catching SIGINT

柔情痞子 提交于 2019-12-06 21:30:08
问题 I am using SDL for an OpenGL application, running on Linux. My problem is that SDL is catching SIGINT and ignoring it. This is a pain because I am developing through a screen session, and I can't kill the running program with CTRL-C (the program the computer is running on is connected to a projector and has no input devices). Is there a flag or something I can pass to SDL so that it does not capture SIGINT? I really just want the program to stop when it receives the signal (ie when I press