Narf03 wrote:oh, a master. hi ya =)
err i donno about that too, im new to both linux and python, but when its shutting down, the pi do broadcast some sort of shut down notice, donno how to intercept this as well. i think intercept the kill signal maybe too late to do anything.
I am not an expert on unix/Linux (they're pretty similar, both working the POSIX spec these days), but I beleive that the first thing that will happen is that the system will send a 'kill' signal to a process, basically asking it to shut down nicely. If that fails to do the trick, the system will then do a "sure kill" aka "kill -9" to terminate the process immediately.
*If* a Python program can have error handling routines that deal with signals from the system, *then* it should be able to react to the initial kill signal and shut itself down before the system decides to do the sure kill.
(You could actually test this by, while running your program, issuing a kill to the process ID of your program. You could also try a kill -9 to see the difference. But check the manual page (use "man kill" to see it) to make sure that's still the sure kill flag.)