Wednesday, February 16, 2005

Unix Signal Handling through Python

I have a script that I need to have reset every few hours. To do this I am using some signal handling stuff.

First import the signal handling stuff
import signal

Then in the main function which traps the signal you would have:
signal.signal(signal.SIGUSR1, sighandler)

when the USR1 signal is issued the sighandler function is called. This function would look something like this:

def sighandler(signum, frame):
   print "Your resetting code here"

Now in the crontab you can put in code where you issue a
kill -USR1 pidofapp

Obviously you will have to save the processes PID to a file, so you can use it later.

Mozilla and hypocrisy

Right, but what about the experiences that Mozilla chooses to default for users like switching to  Yahoo and making that the default upon ...