signals

Qt resize event for docks

孤街浪徒 提交于 2019-12-06 02:58:40
问题 Is there a way to catch resize events for docks in Qt? I need to be able to detect when a dock is resized (and not only when its location or 'features' change). It looks like there is no 'resized' signal for QDockWidget. 回答1: If you do not wish to subclass to just get resize event control, you can installEventFilter Small example would look like ( MainWindow.h ): (MainWindow holds DockWidget Here) protected: bool eventFilter(QObject *obj, QEvent *event); and in ( MainWindow.cc ): MainWindow:

Are there suspend\resume signals in Linux?

扶醉桌前 提交于 2019-12-06 02:05:28
问题 My application needs to react on hibernation mode so it can do some action on suspending and other actions on resuming. I've found some distributive-specific ways to achieve it(Upower + DBus) but didn't find anything universal. Is there a way to do it? Thanks! 回答1: A simple solution to this is to use a self-pipe. Open up a pipe and periodically write timestamps to it. select on this pipe to read the timestamps and compare them to the current time. When there is a big gap, that means you have

QThread finished() connected to deletelater of a QObject

僤鯓⒐⒋嵵緔 提交于 2019-12-06 01:14:14
问题 I have thought a lot and read lot of articles before asking this question here. None of the articles gave me a proper answer. http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/ QThread* thread = new QThread; Worker* worker = new Worker(); worker->moveToThread(thread); connect(worker, SIGNAL(error(QString)), this, SLOT(errorString(QString))); connect(thread, SIGNAL(started()), worker, SLOT(process())); connect(worker, SIGNAL(finished()), thread,

“Proper” way to handle signals other than SIGINT in Python?

雨燕双飞 提交于 2019-12-06 01:01:14
I had some Python code that needed to be able to handle SIGINT. For this purpose I used something like this: def mymethod(*params): obj = MyObj(params) try: obj.do_some_long_stuff() except KeyboardInterrupt: obj.cleanup() Awesome and really straightforward. Yay, Python is great! However, I now need to also handle other signals, namely SIGTSTP and SIGQUIT. What I'm trying to do is something similar. Here's some pseudocode demonstrating what I'm trying to do with SIGTSTP (I hope it's clear enough): def mymethod(*params): obj = MyObj(params) try: obj.do_some_long_stuff() catch SIGINT: obj.cleanup

how to get stdout of subprocess in python when receving SIGUSR2 /SIGINT

你。 提交于 2019-12-06 00:39:48
I have the following simple python script: import os, subprocess,signal,sys import time out = None sub = None def handler(signum,frame): print("script.py: cached sig: %i " % signum) sys.stdout.flush() if sub is not None and not sub.poll(): print("render.py: sent signal to prman pid: ", sub.pid) sys.stdout.flush() sub.send_signal(signal.SIGTERM) sub.wait() # deadlocks....???? #os.kill(sub.pid, signal.SIGTERM) # this works #os.waitpid(sub.pid,0) # this works for i in range(0,5): time.sleep(0.1) print("script.py: cleanup %i" % i) sys.stdout.flush() sys.exit(128+signum) signal.signal(signal.SIGINT

Interprocess synchronization using signals in c, linux

半腔热情 提交于 2019-12-06 00:28:53
Process A forks say 4 child processes. exec() is used to replace the code of the children. The children initialize and have to wait for the parent to create all of the 4 of them. Then the parent sends a sigusr1 to each child process in order for them to start processing. The parent waits for all the children to complete procesing. When a child finishes its work it sends a sigusr2 to the parent. When the parent receives all the sigusr2 signals it continues with execution, merging the calculations of the child processes. This is a university exercise, and it was stated in class that process A

What is the key combination to send a SIGSTOP signal on terminal?

穿精又带淫゛_ 提交于 2019-12-06 00:28:48
It is not Ctrl+Z. That is for SIGTSTP . Also, stty -a shows ^S as the combination but it doesn't seem to work. There is no key combination to send SIGSTOP. Control-S tells the terminal driver to suspend output, but does not send a signal to the process. Control-Q resumes output. 来源: https://stackoverflow.com/questions/8513923/what-is-the-key-combination-to-send-a-sigstop-signal-on-terminal

How to deal with errno and signal handler in Linux?

六月ゝ 毕业季﹏ 提交于 2019-12-05 22:54:32
When we write a signal handler that may change the errno, should we save errno at the beginning of the signal handler and restore the errno at the end of it? Just like below: void signal_handler(int signo){ int temp_errno = errno; *** //code here may change the errno errno = temp_errno; } The glibc documentation says : signal handlers that call functions that may set errno or modify the floating-point environment must save their original values, and restore them before returning. So go ahead and do that. To those reading this who can't rewrite their signal handlers, there may be a workaround.

How to really test signal handling in Python?

北慕城南 提交于 2019-12-05 21:34:04
问题 My code is simple: def start(): signal(SIGINT, lambda signal, frame: raise SystemExit()) startTCPServer() So I register my application with signal handling of SIGINT , then I start a start a TCP listener. here are my questions: How can I using python code to send a SIGINT signal? How can I test whether if the application receives a signal of SIGINT, it will raise a SystemExit exception? If I run start() in my test, it will block and how can I send a signal to it? 回答1: First of, testing the

Perl signal handlers are reset in END blocks

◇◆丶佛笑我妖孽 提交于 2019-12-05 21:21:08
This works as expected since Perl 5.10.1: SIGINTs are trapped. #!/usr/bin/perl use strict; use warnings; $SIG{INT} = sub { die "Caught a sigint $!" }; sleep(20); But here SIGINTs are not trapped. #!/usr/bin/perl use strict; use warnings; $SIG{INT} = sub { die "Caught a sigint $!" }; END { sleep(20); } This can be fixed by setting the handler again in the END block, like so: END { $SIG{INT} = sub { die "Caught a sigint $!" }; sleep(20); } But that won't work if you have more than one block: handlers must be set again for every block. I've tried to figure this out and I can't find an explanation