signals

How do I catch a KILL or HUP or User Abort signal?

萝らか妹 提交于 2020-01-13 08:26:07
问题 I have a script running on the background of my linux server and I would like to catch signals like reboot or anything that would kill this script and instead save any importante information before actually exiting. I think most of what I need to catch is, SIGINT, SIGTERM, SIGHUP, SIGKILL. How do catch any of these signals and have it execute an exit function otherwise keep executing whatever it was doing ? pseudo perl code: #!/usr/bin/perl use stricts; use warnings; while (true) { #my happy

Python core dump on sys.exit() from signal handler

北城以北 提交于 2020-01-13 06:14:08
问题 I am seeing python core dump for a seemingly harmless program. I have written following piece of code to demonstrate my problem: proc = None def __signalHandler(signum, frame): print "In __signalHandler" if proc is not None: print "Send signal to BG proc" os.killpg(os.getpgid(proc.pid), signal.SIGINT) print "Wait for it to finish" proc.communicate() print "sys exit" sys.exit(130) signal.signal(signal.SIGINT, __signalHandler) # Start the process proc = subprocess.Popen(["a.out"], stdout

PyQt_PyObject equivalent when using new-style signals/slots?

前提是你 提交于 2020-01-12 17:31:31
问题 So I have a need to pass around a numpy array in my PyQt Application. I first tried using the new-style signals/slots, defining my signal with: newChunkToProcess = pyqtSignal(np.array()) , however this gives the error: TypeError: Required argument 'object' (pos 1) not found I have worked out how to do this with the old-style signals and slots using self.emit(SIGNAL("newChunkToProcess(PyQt_PyObject)"), np.array([5,1,2])) - (yes, that's just testing data :), but I was wondering, is it possible

PyQt_PyObject equivalent when using new-style signals/slots?

偶尔善良 提交于 2020-01-12 17:30:02
问题 So I have a need to pass around a numpy array in my PyQt Application. I first tried using the new-style signals/slots, defining my signal with: newChunkToProcess = pyqtSignal(np.array()) , however this gives the error: TypeError: Required argument 'object' (pos 1) not found I have worked out how to do this with the old-style signals and slots using self.emit(SIGNAL("newChunkToProcess(PyQt_PyObject)"), np.array([5,1,2])) - (yes, that's just testing data :), but I was wondering, is it possible

Terminating multithreaded application in C++11 by POSIX signal

最后都变了- 提交于 2020-01-12 07:34:07
问题 I wrote a simple multithreaded application in C++11 on Linux platform and I would like to terminate the server and its running threads by sending SIGINT signal. Obviously my server application uses thread support from C++11 ( std::thread etc.). Although I found some support for signal handling in C++11 ( std::signal ), I couldn't find any support for handling signals in multithreaded environment. So my question is - is there any way how to handle signals in multithreaded application in C++11

How can I tell unicorn to understand Heroku's signals?

ぃ、小莉子 提交于 2020-01-12 07:26:07
问题 Perhaps you've seen this... 2012-03-07T15:36:25+00:00 heroku[web.1]: Stopping process with SIGTERM 2012-03-07T15:36:36+00:00 heroku[web.1]: Stopping process with SIGKILL 2012-03-07T15:36:36+00:00 heroku[web.1]: Error R12 (Exit timeout) -> Process failed to exit within 10 seconds of SIGTERM 2012-03-07T15:36:38+00:00 heroku[web.1]: Process exited with status 137 This is a well known problem when running unicorn on heroku... heroku uses SIGTERM for graceful shutdown unicorn uses SIGTERM for

What are the differences between event and signal in Qt

一个人想着一个人 提交于 2020-01-10 08:49:54
问题 It is hard for me to understand the difference between signals and events in Qt, could someone explain? 回答1: An event is a message encapsulated in a class ( QEvent ) which is processed in an event loop and dispatched to a recipient that can either accept the message or pass it along to others to process. They are usually created in response to external system events like mouse clicks. Signals and Slots are a convenient way for QObject s to communicate with one another and are more similar to

Is there a way to declared a QT signal that can only be listened in within enclosing class?

丶灬走出姿态 提交于 2020-01-07 06:35:31
问题 QT signals are by default protected, which means they can be emitted in the object but can be listened anywhere. But some signals are implementation details and I'm struggling to find a way to not let it go out of the class scope. Is there a way to do it? Update: I want to use signals because I want to queue some lower priority tasks rather than handle them promptly at the point of emit/call. Is it a bad idea to use Qt::QueuedConnection for this purpose? 来源: https://stackoverflow.com

Some wrong about sigsetjmp

给你一囗甜甜゛ 提交于 2020-01-06 19:51:32
问题 I am reading the APUE, Chapter 10. Here is my code. #include "apue.h" #include <unistd.h> #include <setjmp.h> #include <time.h> #include <errno.h> static void sig_usr1(int), sig_alrm(int); static sigjmp_buf jmpbuf; static volatile sig_atomic_t canjmp; int main(void) { if(signal(SIGUSR1, sig_usr1) == SIG_ERR) err_sys("signal(SIGUSR1) error"); if(signal(SIGALRM, sig_alrm) == SIG_ERR) err_sys("signal(SIGALRM) error"); //print signal. pr_mask("Starting main: "); if(sigsetjmp(jmpbuf, 1)) { pr_mask

How can i plot the sum of two discrete signal?

ε祈祈猫儿з 提交于 2020-01-06 16:21:10
问题 I have a discrete signal x = [ 1 2 3 4 5 6 ] with n = [ -2 -1 0 1 2 3 ] How can i plot y[n] = x[n-1] + x[n-2] + x[n] ? Thanks. 回答1: You can do the following: y = x(1:end-2) + x(2:end-1) + x(3:end); plot(n(3:end), y) 回答2: This looks like a filter... You should consider using the filter function to calculate y : x = [...whatever...]; % Filter coefficients from your difference equation. b = [1 1 1]; a = 1; y = filter(b, a, x); plot(n, y); This will handle initial conditions more appropriately