signals

Can I set a single signal handler for all signals in Perl?

Is it possible in Perl to install only one signal handler for all the signals it receive? The reason behind this is, I am not aware of what signal my Perl code will get at run time. One way I can see is that point all the available signals to my custom signal handler, but I don't want to go this way. Is there any easy way to do this? som...

Sending SIGSTOP to a child process stops all execution. C

When I call kill(Child_PID, SIGSTOP); from the parent, I expect the child to halt execution and the parent to continue. Is that the expected behavior or do I have to explicitly declare the SIGSTOP handler in the child? I have searched everywhere and not been able to find this information. Thanks. Braden ...

How can I send a signal to a popen'ed process in Perl?

I wrote a simple Perl script which will run in while loop and exit whenever any signal is send to this Perl script. I wrote a c program which creates a thread using the pthread_create() and in its start routine, it's using popen to execute that Perl script: popen("/usr/bin/perl myprog.pl"); I am using the sigtrap in the Perl script to...

How can I catch SIGINT in threading python program?

Hello. When using threading module and Thread() class, SIGINT (Ctrl+C in console) could not be catched. Why and what can I do? Simple test program: #!/usr/bin/env python import threading def test(suffix): while True: print "test", suffix def main(): for i in (1, 2, 3, 4, 5): threading.Thread(target=test, ar...

The usage of sig_atomic_t in linux signal mask function

I was recently studying the book named Advanced Linux Programming and I ran into this question: The book said you should use sig_atomic_t variable type to be sure that if you set a global flag or counter in a signal handler function, context switch does not occur between the arithmetic operations(i.e. ++) and saving those into a register...

PyQt and QSignalMapper/lambdas - multiple signals, single slot

Hi. I have a list of actions on a menu in PyQt, one for each different feed I want to display. So I have a Y that sets the active feed to Y, Z sets it to Z, etc. (For a webcomic reading program). I have each on the menu, and felt that an automated approach might be better; rather than typing out each time. Something like a function tha...

How can I get DBD::Pg to time out reliably?

Why doesn't this code execute the signal handler until after $sth->execute completes? And more importantly, how can I fix it? #!/usr/bin/perl use strict; use warnings; use DBI; use Sys::SigAction qw( set_sig_handler ); my $dbh = DBI->connect('dbi:Pg:dbname=dc'); eval { my $h = set_sig_handler('ALRM', sub { die "timeout\n" }); ...

SIGKILL signal Handler

Hi, I have a requirement to write to a log file on reception of any terminate command like SIGTERM AND SIGKILL. I can register for SIGTERM but how can handle the SIGKILL signal? ...

Can I Force MATLAB to quit after user presses Control-C?

I'm running MATLAB (command line version) from a shell script, and I'd like it to preserve shell behavior where if you press Ctrl-C it exits. But instead it wants to keep control of the terminal and I (or my poor users after me) have to type quit(1) to make it quit and tell the shell it failed. You can't intercept Ctrl-C with a try/cat...

problems in select() and sending a signal SIGUSR1 in the end (C language)

HI, I'm implementing a classical map-reduce program in which I have a parent that spwans N children(maps) + 1(reduce). The parent sends info, through unnamed pipes, to each one of the N children. The maps process the request and send the result, an int, to reduce. The reduce does a select and sums up every counter writen on the pipes fr...

Easy way to send a signal to direct children only?

Is there an easy way to signal only direct children of a process? That is, if A spawns B1 and B2, and the B's spawn C's, can A easily signal just the B's? It seems like it should be relatively simple, but I can't find anything, and I'd rather not do anything complicated if I don't have to. ...

Advice on django form change emailing

Goal: On submission of a form to add/update/delete objects an email is sent out with the current contents of the DB object and the new contents of the DB object in html. Example Object Title was oldTitle and has been changed to newTitle Object Date was oldDate and has been changed to newDate My assumption this can be done two d...

detect when column in gtk.treeview is resized

What signal can I catch to detect when a column changes size in a gtk.TreeView? I can't seem to find it in the docs. ...

What is correct way to have single Signal Handler function for multiple Signals?

What is the best way in C on Linux for setting up a program that can handle multiple POSIX-signals with the same function? For example in my code I have a handler function that I want to generically call when ever a signal is caught to perform some actions: /* Exit handler function called by sigaction */ void exitHandler( int sig, sigi...

Restore serial port attributes even after control-C?

When using a serial port via POSIX, it's recommended to save the original attributes using tcgetattr() before changing them with tcsetattr(), and then restore them before closing the port. What about when a program is terminated by pressing control-C or when the program receives SIGINT? I haven't seen this covered in any of the serial tu...

Unix process synchronization without pthreads/sempahores, signals?

Hello, I am attempting to write a program that doesn't use pthreads or semaphore libraries. I want to do some synchronization with signals. I have read about them in a few Unix books, but I still don't quite get it. I wrote up some mock program design/code, this isn't my program but it gives an idea of how I am trying to organize process...

signal.alarm() handler causing problem with pyserial

so i have a motion sensor connected to an avr micro that is communicating with my python app via usb. im using pyserial to do the comm. during my script i have an infinate loop checking for data from the avr micro. before this loop i start a timer with signal.alarm() that will call a function to end a subprocess. when this alarm goes it ...

How to interrupt python multithreaded app?

I'm trying to run the following code (it i simplified a bit): def RunTests(self): from threading import Thread import signal global keep_running keep_running = True signal.signal( signal.SIGINT, stop_running ) for i in range(0, NumThreads): thread = Thread(target = foo) ...

Does sleep ges interrupted when any signal is received in perl?

I have this simple perl daemon: #!/usr/bin/perl use strict; use warnings; use Proc::Daemon; Proc::Daemon::Init; my $continue = 1; $SIG{TERM} = sub { $continue = 0 }; $SIG{USR1} = sub { do_process(1) }; # basic daemon boxesd_log("started boxesd"); ...

What do you think about NResponder?

Hi, I was on the point of start using AS3 Signals for my new project because Native Events has a bad reputation, and then I found this: http://code.google.com/p/nineveh-responder/ But I couldn't find more information (in addition to official docs and tuts). What do you think about NResponder? OT: I can't create the tag "NResponder" in ...