diff options
author | LRN <lrn1986@gmail.com> | 2012-07-12 21:06:27 +0000 |
---|---|---|
committer | LRN <lrn1986@gmail.com> | 2012-07-12 21:06:27 +0000 |
commit | 1ddd74011af93e1e166d9de48542b0a23f1e1405 (patch) | |
tree | aa0550b801e72a39899d2a6340a796ec7417083b /contrib | |
parent | 4d1707340ffd21eafab733607b03ef3f433b80ef (diff) | |
download | gnunet-1ddd74011af93e1e166d9de48542b0a23f1e1405.tar.gz gnunet-1ddd74011af93e1e166d9de48542b0a23f1e1405.zip |
W32: safer process termination
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/Makefile.am | 2 | ||||
-rw-r--r-- | contrib/gnunet_janitor.py.in | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 0d6539330..aaab287a8 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am | |||
@@ -13,6 +13,7 @@ timeout_watchdog_SOURCES = \ | |||
13 | endif | 13 | endif |
14 | 14 | ||
15 | noinst_SCRIPTS = \ | 15 | noinst_SCRIPTS = \ |
16 | terminate.py \ | ||
16 | gnunet_pyexpect.py \ | 17 | gnunet_pyexpect.py \ |
17 | gnunet_janitor.py | 18 | gnunet_janitor.py |
18 | 19 | ||
@@ -28,6 +29,7 @@ EXTRA_DIST = \ | |||
28 | hostlist.cgi \ | 29 | hostlist.cgi \ |
29 | hostlist.php \ | 30 | hostlist.php \ |
30 | report.sh \ | 31 | report.sh \ |
32 | terminate.py.in \ | ||
31 | gnunet_pyexpect.py.in \ | 33 | gnunet_pyexpect.py.in \ |
32 | gnunet_janitor.py.in \ | 34 | gnunet_janitor.py.in \ |
33 | gnunet-gns-import.sh | 35 | gnunet-gns-import.sh |
diff --git a/contrib/gnunet_janitor.py.in b/contrib/gnunet_janitor.py.in index 056ab9bc4..69186fde6 100644 --- a/contrib/gnunet_janitor.py.in +++ b/contrib/gnunet_janitor.py.in | |||
@@ -30,13 +30,11 @@ import sys | |||
30 | import shutil | 30 | import shutil |
31 | import time | 31 | import time |
32 | import signal | 32 | import signal |
33 | import terminate | ||
33 | 34 | ||
34 | if os.name == 'nt': | 35 | if os.name == 'nt': |
35 | from win32com.client import GetObject | 36 | from win32com.client import GetObject |
36 | WMI = GetObject('winmgmts:') | 37 | WMI = GetObject('winmgmts:') |
37 | killsignal = signal.SIGTERM # any valid value will result in TerminateProcess() | ||
38 | else: | ||
39 | killsignal = signal.SIGKILL | ||
40 | 38 | ||
41 | def get_process_list (): | 39 | def get_process_list (): |
42 | result = [] | 40 | result = [] |
@@ -63,7 +61,7 @@ def main (): | |||
63 | if re.match (r'gnunet-service-arm', p[1]): | 61 | if re.match (r'gnunet-service-arm', p[1]): |
64 | print ("killing arm process {0:5} {1}".format (p[0], p[1])) | 62 | print ("killing arm process {0:5} {1}".format (p[0], p[1])) |
65 | try: | 63 | try: |
66 | os.kill (int (p[0]), killsignal) | 64 | terminate.safe_terminate_process_by_pid (int (p[0]), 1) |
67 | except OSError as e: | 65 | except OSError as e: |
68 | print ("failed: {0}".format (e)) | 66 | print ("failed: {0}".format (e)) |
69 | pass | 67 | pass |
@@ -71,7 +69,7 @@ def main (): | |||
71 | if not re.match (r'gnunet-service-arm', p[1]): | 69 | if not re.match (r'gnunet-service-arm', p[1]): |
72 | print ("killing non-arm process {0:5} {1}".format (p[0], p[1])) | 70 | print ("killing non-arm process {0:5} {1}".format (p[0], p[1])) |
73 | try: | 71 | try: |
74 | os.kill (int (p[0]), killsignal) | 72 | terminate.safe_terminate_process_by_pid (int (p[0]), 1) |
75 | except OSError as e: | 73 | except OSError as e: |
76 | print ("failed: {0}".format (e)) | 74 | print ("failed: {0}".format (e)) |
77 | pass | 75 | pass |