signals

How to properly terminate a thread in a signal handler?

我是研究僧i 提交于 2020-02-16 03:04:19
问题 I want to set up a signal handler for SIGSEGV, SIGILL and possibly a few other signals that, rather than terminating the whole process, just terminates the offending thread and perhaps sets a flag somewhere so that a monitoring thread can complain and start another thread. I'm not sure there is a safe way to do this. Pthreads seems to provide functions for exiting the current thread, as well as canceling another thread, but these potentially call a bunch of at-exit handlers. Even if they don

Saving work after a SIGINT

醉酒当歌 提交于 2020-02-02 04:35:08
问题 I have a program which takes a long time to complete. I would like it to be able to catch SIGINT (ctrl-c) and call the self.save_work() method. As it stands, my signal_hander() does not work since self is not defined by the time the program reaches signal_handler() . How can I set it up so self.save_work gets called after a SIGINT ? #!/usr/bin/env python import signal def signal_handler(signal, frame): self.save_work() # Does not work exit(1) signal.signal(signal.SIGINT, signal_handler) class

C signal handler getting activated by all child processes

本秂侑毒 提交于 2020-01-25 21:27:28
问题 I need some kind of signal_handler that when pressed CTRL+C, the program pauses all it's operations and asks the user: «Are you sure you want to terminate(Y/N)?» If the answer is y, the program terminates, if it's n the program continues/prooceeds with it's functions, this is what i have till this moment: void sig_handler(int sig){ if(sig == SIGINT){ char res; printf("\nAre you sure you want to terminate (Y/N)?\n"); kill(0, SIGTSTP); //envia sinal Stop ao processo pai do{ read(STDIN_FILENO,

SIGSTOP and SIGCONT equivalent in threads

丶灬走出姿态 提交于 2020-01-24 07:25:27
问题 Is there something equivalent to SIGSTOP and SICONT for threads? Am using pthreads. Thanks An edit: I am implementing a crude form of file access syncronization among threads. So if a file is already opened by a thread, and another thread wants to open it again, I need to halt or pause the second thread at that point of its execution. When the first thread has completed its work it will check what other threads wanted to use a file it released and "wake" them up. The second thread then

SIGSTOP and SIGCONT equivalent in threads

北城以北 提交于 2020-01-24 07:25:04
问题 Is there something equivalent to SIGSTOP and SICONT for threads? Am using pthreads. Thanks An edit: I am implementing a crude form of file access syncronization among threads. So if a file is already opened by a thread, and another thread wants to open it again, I need to halt or pause the second thread at that point of its execution. When the first thread has completed its work it will check what other threads wanted to use a file it released and "wake" them up. The second thread then

Signal Handling on Linux when using Java/JNI

我与影子孤独终老i 提交于 2020-01-23 14:36:35
问题 I work on an embedded system running on Wind River Linux. It is a mix of Java and C++ with some JNI for communication between technologies. We have build custom error handling so that in the event of any unexpected errors we generate backtraces and other information to help us determine the problem. This error handling is always done by a C++ component that all other components must register with (so that the appropriate signals handlers can be installed). So in the case of a Java component

Signal Handling on Linux when using Java/JNI

安稳与你 提交于 2020-01-23 14:35:24
问题 I work on an embedded system running on Wind River Linux. It is a mix of Java and C++ with some JNI for communication between technologies. We have build custom error handling so that in the event of any unexpected errors we generate backtraces and other information to help us determine the problem. This error handling is always done by a C++ component that all other components must register with (so that the appropriate signals handlers can be installed). So in the case of a Java component

signals sent by qtcreator on “stop”

五迷三道 提交于 2020-01-22 21:23:10
问题 I am working on linux and I realized that my application was leaving behind daemon processes when I close it with the "Stop" button on Qt creator IDE. I want to handle these cases so the application close the same way as when I close the main window. To write the handlers, I need to know which signals it corresponds to. 回答1: Digging into QtCreator's code, I can see that QtCreator uses a QProcess internally to launch your app. The red "stop" button is connected to ApplicationLauncher::stop() ,

Handling CTRL+C event in Node.js on Windows

北战南征 提交于 2020-01-22 18:19:05
问题 I am working on a node project where I want to write some memory to file when exiting. I figured it was as simple as: process.on('exit', function () { //handle your on exit code console.log("Exiting, have a nice day"); }); However, this code does not execute (on Windows) when CTRL+C is received. Given this is the defacto way to exit Node, this seems a bit of a problem. At this point I tried to handle the signal ( on.('SIGINT',...) ) instead, which results in the error: node.js:218 throw e; //

Asynchronous signals with asyncio

不想你离开。 提交于 2020-01-22 12:22:08
问题 My model post processing is using the post_save signal: from django.core.signals import request_finished from django.dispatch import receiver from models import MyModel from pipeline import this_takes_forever @receiver(post_save, sender=MyModel) def my_callback(sender, **kwargs): this_takes_forever(sender) The this_takes_forever routine does IO so I want to defer it to avoid blocking the request too much. I thought this was a great use case for the new asyncio module. But I have a hard time