# -*- coding: utf-8 -*-
-
# Public Domain
#
# Copyright 2007, 2009 Sander Marechal <s.marechal@jejik.com>
import os
import sys
import time
-from signal import signal, SIGTERM
+from signal import signal, SIGTERM, SIGHUP, SIGUSR1
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.
"""
"""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: