Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Do not rely on SIGINT handler, use own handler instead
Browse files Browse the repository at this point in the history
In some scenarios (e.g. our internal build server), the handler for SIGINT
is signal.SIG_IGN, i.e. the signal is ignored. In this case, the daemon will
not stop and the init script will eventually send SIGKILL, which prevents
a clean shutdown.
  • Loading branch information
Stefan Nordhausen committed Aug 22, 2016
1 parent ab0bc73 commit b674f4d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/python/succubus/daemonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ def daemonize(self):
pid = os.getpid()
file(self.pid_file, 'w+').write("%s\n" % pid)

# Handle SIGTERM the same as SIGINT: raise a KeyboardInterrupt.
signal.signal(signal.SIGTERM, signal.getsignal(signal.SIGINT))
def handler(*args):
raise BaseException("SIGTERM was caught")
signal.signal(signal.SIGTERM, handler)
# atexit functions are "not called when the program is killed by a
# signal not handled by Python". But since SIGTERM is now handled, the
# atexit functions do get called.
Expand Down

0 comments on commit b674f4d

Please sign in to comment.