signals

Is emitting a disconnected signal bad?

I defined a signal in myapp and emit it in very different places within code, but I need it just when my MY_DEFINED_FLAG is defined, my question is: Do I should change every: emit mySignal(); to #ifdef MY_DEFINED_FLAG emit mySignal(); #endif ? and if the answer is "yes" then, is there a better idea? ...

C: signal function (parameters?)

I have the following c code: void handler(int n) { printf("n value: %i\n"); } int main() { signal(SIGTSTP, handler); // ^Z at keyboard for(int n = 0; ; n++) { } } I am curious what the n parameter is in the handler function. When you press ^Z it usually prints either: 8320, -1877932264 or -1073743664. What are ...

PHP on windows and signal handling

Hello, I have a standalone PHP script and I would handle signal sent from Windows OS to do a graceful shutdown when "kill signal" is issued. Do you know what to do that on Windows OS? Thank's in advance. Regards, Alberto ...

Linux and C : How to do a cleanup after SIGKILL ?

Hi. I'm working on a program which uses shared memory. Multiple instances of said program will either connect to an existing one or create it anew, and give it back to OS when there are no other processes or just detach it and terminate. I thought of using a simple counter to keep track of how many processes use it. I'm using atexit() ...

Qt signals inheritance?

EDIT: I provided an answer but I'd be happy to accept another one that provides an explanation. I subclassed QPushButton to add some functionality, but after connection the clicked signal to a slot, it doesn't get called. If I use a vanilla QPushButton, and don't change anything else, it works. Here's the code: /// --- imagebutton.h #...

signals and slots in multilayered UI widgets

Let's say we have the follogin UI: +--------------------------+ |W1 +--------------+ | | |W2 | | | | +----------+ | | | | |W3 | | | | | +----------+ | | | | | | | +--------------+ | +--------------------------+ W3 is interested in a certain signal emi...

Infinity Loop and user input as the termination

I have my code and it does go run to infinity. What I want is that if on the unix command window if the user inputs a ctrl C, I want the program to finish the current loop it in and then come out of the loop. So I want it to break, but I want it to finish the current loop. Is using ctrl C ok? Should I look to a different input? ...

Kiling processes in C with Signals

The main process in my program forks 3 more process with say process ids as pid1, pid2, pid3. Pid1 and pid2 processes are in infinite loop. What I want is when pid3 process is over all the process including the main are terminated. As of now, I am using : wait(pid3); kill(0, SIGKILL); which do all above as i said, but it prints Killed...

Getting IOError when using pre_save signal to store a thumbnail

I have a model that has an option photo field. When a photo is added, I want a thumbnail to be automatically created and stored. However, when I do this with a pre_save signal, I keep getting an IOError, and if I try to do it with a post_save signal I can't save the thumbnails path to my model without creating and infinite post_save loop...

Is it possible to change the signal handlers in another process?

I found out the nohup tool today, and was wondering about it's implementation. Specifically, it seems like there must be a way to tell another process, or a child process, to ignore certain signals. Is there a system call, or something like that, that does this? ...

asynchronous Inter thread communication

Hi, I'm making a cross plateform program that embbed a small RARP server (implemented with winpcap/pcap) and runs 2 TCP IP servers. I have to use C++. So i will have at least 4 threads, the main one wich countain the controller, 2 TCP/IP async socket, and the RARP server. I planned to use c++ BOOST Asio and Thread, because i need to r...

How do I prevent fixtures from conflicting with django post_save signal code?

In my application, I want to create entries in certain tables when a new user signs up. For instance, I want to create a userprofile which will then reference their company and some other records for them. I implemented this with a post_save signal: def callback_create_profile(sender, **kwargs): # check if we are creating a new User...

PyQt4 Threading: Sending data back to a thread

I'm writing a program, with a PyQt frontend. To ensure that the UI doesn't freeze up, I use QThreads to emit signals back to the parent. Now, I have reached a point where I need my thread to stop running, emit a signal back to the parent, then wait on the parent to return an approval for the thread to continue (after the user interacts...

Performance impact for specifying qualitative temporal information in Django signals?

When defining a Signal in Django, should you specify qualitative temporal information such as pre and post in the name of the Signal, or as an argument? If as an argument, what range of values should you use? For instance, say I want to define Signals before and after an operation X, one way is: pre_x_signal = Signal(providing_args = [...

ptrace'ing multithread application

Hello I have a "debugger"-like application, named hyper-ptrace. It starts user_appl3 which is multithreaded with NPTL. Main loop of hyper-ptrace is: wait3(&status, FLAGS, &u); // find a pid of child, which has a signal switch (signal = WSTOPSIG(status)) { case SIGTRAP: do_some_analysis_of_the_child(pid, &status) // up to several...

Signal passing to managed processes using supervisord

I am using supervisord to spawn and manage a FastCGI application that I am writing in C for a linux target. I have a signal handler that gracefully exits my application when SIGINT is received. I have verified that the signal handler works as desired by running the app in a terminal window and issuing Ctrl-C to exit. When issuing a "sh...

log rotation for nginx on windows

I've found plenty of references on the web for rotating the nginx logs under linux.. just send the USR1 signal to the process. But... unix like signals don't exist on windows and I haven't been able to find any information on this. How can I accomplish the same thing with nginx on windows?? ...

How to insulate a job/thread from crashes

I'm working on a library where I'm farming various tasks out to some third-party libraries that do some relatively sketchy or dangerous platform-specific work. (In specific, I'm writing a mathematical function parser that calls JIT-compilers, like LLVM or libjit, to build machine code.) In practice, these third-party libraries have a t...

KeyError when trying to save model instance. Django.

KeyError when trying to save model instance. It has to react on post_save signal than save instance... Code: from django.db.models.signals import post_save class PlaylistEntry(models.Model): playlist=models.ForeignKey(Playlist) media=models.ForeignKey(Media) order=models.PositiveIntegerField(default=9000000, editable=False...

recv() is not interrupted by a signal in multithreaded environment

I have a thread that sits in a blocking recv() loop and I want to terminate (assume this can't be changed to select() or any other asynchronous approach). I also have a signal handler that catches SIGINT and theoretically it should make recv() return with error and errno set to EINTR. But it doesn't, which I assume has something to do ...