From 494731e5330485fc7cb93101c6ab45a8930e81e7 Mon Sep 17 00:00:00 2001 From: Reese Moore Date: Fri, 7 Oct 2011 16:09:01 -0400 Subject: [PATCH] Make phenny kill the child threads when the parent receives a SIGTERM. --- __init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/__init__.py b/__init__.py index ca35fb0..2d8fa2b 100755 --- a/__init__.py +++ b/__init__.py @@ -15,6 +15,7 @@ class Watcher(object): def __init__(self): self.child = os.fork() if self.child != 0: + signal.signal(signal.SIGTERM, self.sig_term) self.watch() def watch(self): @@ -27,6 +28,10 @@ class Watcher(object): try: os.kill(self.child, signal.SIGKILL) except OSError: pass + def sig_term(self, signum, frame): + self.kill() + sys.exit() + def run_phenny(config): if hasattr(config, 'delay'): delay = config.delay