aboutsummaryrefslogtreecommitdiff
path: root/contrib/gnunet_janitor.py.in
diff options
context:
space:
mode:
authorLRN <lrn1986@gmail.com>2012-07-12 21:06:27 +0000
committerLRN <lrn1986@gmail.com>2012-07-12 21:06:27 +0000
commit1ddd74011af93e1e166d9de48542b0a23f1e1405 (patch)
treeaa0550b801e72a39899d2a6340a796ec7417083b /contrib/gnunet_janitor.py.in
parent4d1707340ffd21eafab733607b03ef3f433b80ef (diff)
downloadgnunet-1ddd74011af93e1e166d9de48542b0a23f1e1405.tar.gz
gnunet-1ddd74011af93e1e166d9de48542b0a23f1e1405.zip
W32: safer process termination
Diffstat (limited to 'contrib/gnunet_janitor.py.in')
-rw-r--r--contrib/gnunet_janitor.py.in8
1 files changed, 3 insertions, 5 deletions
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
30import shutil 30import shutil
31import time 31import time
32import signal 32import signal
33import terminate
33 34
34if os.name == 'nt': 35if 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()
38else:
39 killsignal = signal.SIGKILL
40 38
41def get_process_list (): 39def 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