I think what I am looking for is SetConsoleCtrlHandler(..) which receives signals for CTRL+C and system shutdown. I don't want to take the power outage into account because as far as I can see there is no portable/simple/reliable way to accomplish that. So, thanks for the tip again.
So what is the equivalent of this API in Linux? How can I accomplish the same behavior for Linux? Thanks a lot. -- http://mail.python.org/mailman/listinfo/python-list