signals
Is it possible to capture a Ctrl+C signal (SIGINT) and run a cleanup function, in a “defer” fashion?
I want to capture the Ctrl+C (SIGINT) signal sent from the console and print out some partial run totals. 10 Answers 10
How to prevent SIGPIPEs (or handle them properly)
I have a small server program that accepts connections on a TCP or local UNIX socket, reads a simple command and (depending on the command) sends a reply. The problem is that the client may have no interest in the answer and sometimes exits early. So writing to that socket will cause a SIGPIPE and … Read more
What’s the best way to send a signal to all members of a process group?
I want to kill a whole process tree. What is the best way to do this using any common scripting languages? I am looking for a simple solution. 34 Answers 34 You don’t say if the tree you want to kill is a single process group. (This is often the case if the tree is … Read more
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 … Read more
What killed my process and why?
My application runs as a background process on Linux. It is currently started at the command line in a Terminal window. Recently a user was executing the application for a while and it died mysteriously. The text: Killed was on the terminal. This happened two times. I asked if someone at a different Terminal used … Read more