[tor-commits] [torflow/master] SIGTERM handler to kill child process

mikeperry at torproject.org mikeperry at torproject.org
Fri Jun 24 19:33:53 UTC 2011


commit f0eb6dbaa7c48723a9c49a56f52ddd8bd599e5f1
Author: aagbsn <aagbsn at extc.org>
Date:   Fri Jun 17 18:49:07 2011 -0700

    SIGTERM handler to kill child process
---
 NetworkScanners/BwAuthority/bwauthority.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/NetworkScanners/BwAuthority/bwauthority.py b/NetworkScanners/BwAuthority/bwauthority.py
index cee2044..b1a6197 100644
--- a/NetworkScanners/BwAuthority/bwauthority.py
+++ b/NetworkScanners/BwAuthority/bwauthority.py
@@ -7,6 +7,8 @@ import traceback
 sys.path.append("../../")
 from TorCtl import TorUtil
 from TorCtl.TorUtil import plog
+from signal import signal, SIGTERM
+from sys import exit
 
 
 # exit code to indicate scan completion
@@ -28,7 +30,13 @@ def main(argv):
     else:
       plog('WARN', 'Child process returned %s' % p.returncode)
 
+def sigterm_handler(signum, frame):
+  if p:
+    p.kill()
+  exit()
+
 if __name__ == '__main__':
+  signal(SIGTERM, sigterm_handler)
   try:
     main(sys.argv)
   except KeyboardInterrupt:





More information about the tor-commits mailing list