signals

run code after transaction commit in Django

Is there any way to run some code after transaction commit in Django? I need to send some messages to a rabbitmq server for offline processing, but the message gets to the consumer before the Django transaction is commited. My message is sent in the post_save signal of the model. What I'm looking for is a similar mechanism, using sign...

Multi-threading: Signal vs BusyWait(Polling), Inter-thread condition variables questions

Hello, I have a general Question about inter-thread communication. Right now I am using a bunch of C++ thread (~15). They are all using BusyWait(Polling) each others to get data to process. But it is hard to keep cpu usage low && give good performance and avoiding doing too many context switch. So I am looking at Condition variable, ...

Can the signal system call be used with C++ static members of the class?

Is the following supported across *nix platforms? #include <cstdio> #include <sys/types.h> #include <signal.h> #include <unistd.h> class SignalProcessor { public: static void OnMySignal(int sig_num) { printf("Caught %d signal\n", sig_num); fflush(stdout); return; ...

How can I pass data from a thread to the parent process?

I have a main process that uses a single thread library and I can only the library functions from the main process. I have a thread spawned by the parent process that puts info it receives from the network into a queue. I need to able to tell the main process that something is on the queue. Then it can access the queue and process the ...

Django pre_save signal called when commit=False

I am writing a Django application that will track changes to the models, in a similar way to the admin interface. For example, I will be able to display a list of changes to a model, that look something like Changed Status from Open to Closed. I am using the pre_save signal to do this, comparing the relevant fields between the existing ...

how does a process know when it's been backgrounded?

When I scp a file, I can stop it with ^Z and put it in the background. When it's in the background it stops printing its progress but the copying continues. If I foreground it again, it resumes printing. How does it know? SIGTTOU? does that happen on a standard ptty? ...

Signals don't re-enable properly across execv()

I am writing a system-critical program for a Linux distribution that I am developing. It needs to restart itself on receiving certain signals, to try to avoid crashing. The problem is, after the restart, I cannot re-enable that signal. That is, the signal cannot be received twice. After execv()'ing itself, when the new process calls sign...

Java error: java.lang.IllegalArgumentException: Signal already used by VM: INT

I am investigating a Java issue (using IBM JVM 1.4.2 64-bit) on Red Hat Linux. I am wondering if anyone has seen this error message before and knows if there is a workaround to this problem? Source: import sun.misc.Signal; import sun.misc.SignalHandler; public class SignalTest extends Thread { private static Signal signal = new S...

GTK detecting window resize from the user

In GTK (or pygtk or gtkmm...) How can I detect that an application window has been manually resized by the user, as is typically done by dragging the window's edge? I need to find a way to differentiate manual resizes from resizes that originate from gtk, such as changes in window content. ...

OS X Process control

I'm writing a process-controller kernel extension for leopard. The application enables me to suspend process's with SIGSUS and to make the computer sleep. My problem is when an application that uses video / audio (e.g iTunes or GarageBand) is suspended and then I try to make the computer sleep, the sleep process waits on the audio / vide...

How can I catch SIGSEGV (segmentation fault) and get a stack trace under JNI on Android?

I'm moving a project to the new Android Native Development Kit (i.e. JNI) and I'd like to catch SIGSEGV, should it occur (possibly also SIGILL, SIGABRT, SIGFPE) in order to present a nice crash reporting dialog, instead of (or before) what currently happens: the immediate unceremonious death of the process and possibly some attempt by th...

SIGALRM while sleeping on Solaris 9

I'm running into a bit of a weird error while running Perl in a chroot environment on Solaris 9 (Sparc). We are using a custom Perl, but it's almost exactly Perl 5.8.7, and this version has been running for years on various platforms including Solaris 8-10. The following code is pretty straightforward: #!/usr/bin/perl use strict; use...

Is there a way to list Django signals?

Is there a way to see which signals have been set in Django? ...

Application receiving mysterious SIGINTs

We have a small daemon application written in C for a couple of various UNIX platforms (this problem is happening in SunOS 5.10), that basically just opens up a serial port and then listens for information to come in via said port. In this particular instance, the daemon appears to read a single transmission (like a file's worth of data...

How do I capture SIGINT in Python?

I'm working on a python script that starts several processes and database connections. Every now and then I want to kill the script with a Ctrl-C signal, and I'd like to do some cleanup. In Perl I'd do this: $SIG{'INT'} = 'exit_gracefully'; sub exit_gracefully { print "Caught ^C \n"; exit (0); } How do I do the analogue of th...

glibmm timeout signal

I'm working on a plugin for a smaller application using gtkmm. The plugin I'm working on checks certain conditions (the date had changed and a new day started) after every minute and starts some actions if the conditions are true. In the initialization part of the plugin I have the following piece of code that uses Glib::SignalTimeout an...

MPI signal handling

When using mpirun, is it possible to catch signals (for example, the SIGINT generated by ^C) in the code being run? For example, I'm running a parallelized python code. I can except KeyboardInterrupt to catch those errors when running python blah.py by itself, but I can't when doing mpirun -np 1 python blah.py. Does anyone have a sugge...

TerminateProcess vs Ctrl+C

I have a console-mode program that uses SQLite3 to maintain a database file. It takes a while to execute, but it should be safe at any point to cancel, assuming that the database writes happen. (This is all under Windows) Is it any safer, from the point of a running program, to hit CTRL+C in the console than to have another program ca...

What are the Python thread + Unix signals semantics?

What are the rules surrounding Python threads and how Unix signals are handled? Is KeyboardInterrupt, which is triggered by SIGINT but handled internally by the Python runtime, handled differently? ...

Increasing the number of file descriptors in Linux.

I have a long running process which monitors the system and prints periodic logs. If I let it run for longer than 10-15 minutes, it exits with a message saying: Too many open files. The program is setup using real time timer_create() and timer_settime() which raise a SIGUSR1 every 2 seconds. In the handler, there is one fork()-exec() in...