X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fdaemon.py;h=fa0997686ea4198f9c6550c8dea1474b40c81e74;hb=29344ced1f406ec9a3d718ece10c5a2b183a7b6f;hp=b0b1130172450ac21c0196a4ec05a801f58d4d7e;hpb=ad6abade7a1da313f9ef36494d38a3a927a5aee2;p=mpd-sima.git diff --git a/sima/lib/daemon.py b/sima/lib/daemon.py index b0b1130..fa09976 100644 --- a/sima/lib/daemon.py +++ b/sima/lib/daemon.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Public Domain # # Copyright 2007, 2009 Sander Marechal @@ -27,7 +26,7 @@ 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 +61,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 +123,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: