]> kaliko git repositories - mpd-sima.git/blobdiff - sima/lib/daemon.py
Cleanup PlayerError exception wrapper
[mpd-sima.git] / sima / lib / daemon.py
index b0b1130172450ac21c0196a4ec05a801f58d4d7e..9de08f91fe64f61f7eda87b37ddc41e163afaa32 100644 (file)
@@ -1,11 +1,10 @@
 # -*- coding: utf-8 -*-
-
 # Public Domain
 #
 # Copyright 2007, 2009 Sander Marechal <s.marechal@jejik.com>
 # http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
 #
-# Copyright 2010, 2011 Jack Kaliko <efrim@azylum.org>
+# Copyright 2010, 2011 kaliko <kaliko@azylum.org>
 # https://gitorious.org/python-daemon
 #
 #  This file is part of MPD_sima
 #
 #  You should have received a copy of the GNU General Public License
 #  along with MPD_sima.  If not, see <http://www.gnu.org/licenses/>.
+#
+# pylint: disable=all
 
 import atexit
 import os
 import sys
 import time
-from signal import signal, SIGTERM
+from signal import signal, SIGTERM, SIGHUP, SIGUSR1
 
 
 class Daemon(object):
@@ -62,8 +63,8 @@ class Daemon(object):
         for details (ISBN 0201563177)
 
         Short explanation:
-            Unix processes belong to "process group" which in turn lies within a "session".
-            A session can have a controlling tty.
+            Unix processes belong to "process group" which in turn lies within a
+            "session".  A session can have a controlling tty.
             Forking twice allows to detach the session from a possible tty.
             The process lives then within the init process.
         """
@@ -124,10 +125,16 @@ class Daemon(object):
         """Declare signal handlers
         """
         signal(SIGTERM, self.exit_handler)
+        signal(SIGHUP, self.hup_handler)
+        signal(SIGUSR1, self.hup_handler)
 
     def exit_handler(self, signum, frame):
         sys.exit(1)
 
+    def hup_handler(self, signum, frame):
+        """SIGHUP handler"""
+        pass
+
     def delpid(self):
         """Remove PID file"""
         try: