signals

Callback, specified in QueueUserAPC , does not get called

情到浓时终转凉″ 提交于 2020-01-03 15:33:45
问题 In my code, I use QueueUserAPC to interrupt the main thread from his current work in order to invoke some callback first before going back to his previous work. std::string buffer; std::tr1::shared_ptr<void> hMainThread; VOID CALLBACK myCallback (ULONG_PTR dwParam) { FILE * f = fopen("somefile", "a"); fprintf(f, "CALLBACK WAS INVOKED!\n"); fclose(f); } void AdditionalThread () { // download some file using synchronous wininet and store the // HTTP response in buffer QueueUserAPC(myCallback,

Calling a standard library function in signal handler

主宰稳场 提交于 2020-01-03 15:32:33
问题 Why is calling a standard library function inside a signal handler discouraged? 回答1: This is explained in the GNU LibC documentation. If you call a function in the handler, make sure it is reentrant with respect to signals, or else make sure that the signal cannot interrupt a call to a related function. And just in case, here's the Wikipedia page on reentrant functions. A computer program or routine is described as reentrant if it can be safely called again before its previous invocation has

How to implement the Hough Transform?

為{幸葍}努か 提交于 2020-01-03 12:58:51
问题 How does one implement a Hough transform on a text image? I'm looking for pseudo-code (eventually this will be in java). Here is some background information: Given an image, determine the equation for a line y = mx + b . Typically the Hough Transform is represented in polar co-ordinates such that Rho = y*sin(theta) + x*cos(theta) . (I'm not really sure what the X and Y values correspond to back to the image). we are only interested in the Rho and theta values and plot them. The locations with

How can I send a signal to a process ID in Perl 6?

人盡茶涼 提交于 2020-01-03 09:38:48
问题 Perl 6 has ways to accept signals and to send a signal to a Proc::Async. Although the [p5-p6 perlfunc] docs says that kill works much like is does in Perl 5, it doesn't because you can't send a signal to an arbitrary process ID (doc issue filed). I had a particular program I wanted to write in Perl 6 (for giggles), but was forced to fall back to Perl 5 for lack of a reliable kill. Short of shelling out to kill or tasklist (and taskkill ), is this something we'll just have to do without. There

Associate signal and slot to a qcheckbox create dynamically

元气小坏坏 提交于 2020-01-03 03:39:04
问题 I've got a very specific problem so I'm going to try to be as clear as possible. I've got a QTabWidget which contains QTableWidget , every line of my QTableWidget is create dynamically by reading a file. As you may see, when I create a line, I add a qCheckBox at the end. My goal now, is to send this line to the QTableWidget in the last tab of my QtableTab when I click on the qCheckBox ( and to delete this line when I uncheck the qCheckBox ). So every time I create a line dynamically, I try to

Can linux signal my Qt program when a particular USB device is connected?

房东的猫 提交于 2020-01-03 00:54:13
问题 I want linux to inform my Qt program by a signal when a particular USB device is connected. Storage devices like flash disk or hard drive. How can I do this? What are your suggestions? UPDATE: I have found that QtDbus can provide the functionality that I need but I have not figure out how exactly. Is there anyone can give information about getting USB device notification with QtDbus? I have been reading this tutorial: http://dbus.freedesktop.org/doc/dbus-tutorial.html This tutorial says: D

process handle in lldbinit

我的梦境 提交于 2020-01-02 19:10:47
问题 I'd like to have the following command init my .lldbinit. process handle SIGPROF -n false -p true -s false The problem is that lldb won't run this command when it starts up and doesn't yet have a process. error: Aborting reading of commands after command #1: ' process handle SIGPROF -n false -p true -s false' failed with error: No current target; cannot handle signals until you have a valid target and process. How can I tell lldb to apply this command whenever it does have a process? 回答1: One

signal handler and multithreading

我只是一个虾纸丫 提交于 2020-01-02 10:22:21
问题 I know that signal is a way of communication between CPU and OS kernel. A signal can interrupt the sequence of instructions, execute the handler and go back to the sequence of instructions. Here is a piece of description of this link: When a signal that is being caught is handled by a process, the normal sequence of instructions being executed by the process is temporarily interrupted by the signal handler. The process then continues executing, but the instructions in the signal handler are

Installing SIGTSTP Foreground Process

江枫思渺然 提交于 2020-01-02 10:18:30
问题 I am trying to install a CTRL-Z (SIGTSTP) handler for a running foreground process. I set the handler ( sigaction ) right before I wait in the parent. Is this the right place? It doesn't seem to work right.. EDIT: I am writing a shell. Here is an outline of how my code looks like. I currently set the handler in the parent as shown below (which doesn't seem to work). // input from user for command to run pid_t pid; pid = fork(); // Child Process if (pid == 0) { // handle child stuff here //

Trapping signals in Python

微笑、不失礼 提交于 2020-01-02 08:22:46
问题 According to the documentation: There is no way to “block” signals temporarily from critical sections (since this is not supported by all Unix flavors). What stops me using signal.signal(signum,SIG_IGN) to block it, then adding the signal back? 回答1: What stops you is that, if the signal actually arrives while SIG_IGN is in place, then it will be ignored and thrown away. When you add the signal back later, it's too late because it's gone and you'll never get to learn that it happened. Thus,