]> code.delx.au - bg-scripts/blobdiff - lib/SigHandler.py
Initial import
[bg-scripts] / lib / SigHandler.py
diff --git a/lib/SigHandler.py b/lib/SigHandler.py
new file mode 100644 (file)
index 0000000..9b494d1
--- /dev/null
@@ -0,0 +1,18 @@
+#! python
+
+from signal import signal, SIGHUP, SIGTERM
+
+class HUPInterrupt(Exception):
+       pass
+class TERMInterrupt(Exception):
+       pass
+
+def HUPHandler(signal, stackFrame):
+       raise HUPInterrupt
+
+def TERMHandler(signal, stackFrame):
+       raise TERMInterrupt
+
+# Install the handlers
+signal(SIGHUP, HUPHandler)
+signal(SIGTERM, TERMHandler)