projects
/
oweals
/
gnunet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
towards fixing mysql plugin
[oweals/gnunet.git]
/
contrib
/
gnunet_janitor.py.in
diff --git
a/contrib/gnunet_janitor.py.in
b/contrib/gnunet_janitor.py.in
index c23cc28588fcaf39733ded062be3b38c747ea353..74fc70886490cc059b1b2d611dc3aeb8bcca4c70 100644
(file)
--- a/
contrib/gnunet_janitor.py.in
+++ b/
contrib/gnunet_janitor.py.in
@@
-14,10
+14,14
@@
#
# You should have received a copy of the GNU General Public License
# along with GNUnet; see the file COPYING. If not, write to the
#
# You should have received a copy of the GNU General Public License
# along with GNUnet; see the file COPYING. If not, write to the
-# Free Software Foundation, Inc., 5
9 Temple Place - Suite 330
,
-# Boston, MA 0211
1-1307
, USA.
+# Free Software Foundation, Inc., 5
1 Franklin Street, Fifth Floor
,
+# Boston, MA 0211
0-1301
, USA.
#
# Finds any gnunet processes still running in the system and kills them
#
# Finds any gnunet processes still running in the system and kills them
+#
+# gnunet janitor can be used by invoking `make' like this:
+# TESTS_ENVIRONMENT='${top_srcdir}/contrib/gnunet_janitor.py &&' make check
+
from __future__ import print_function
import os
import re
from __future__ import print_function
import os
import re
@@
-26,6
+30,7
@@
import sys
import shutil
import time
import signal
import shutil
import time
import signal
+import terminate
if os.name == 'nt':
from win32com.client import GetObject
if os.name == 'nt':
from win32com.client import GetObject
@@
-40,7
+45,10
@@
def get_process_list ():
else:
pids = [pid for pid in os.listdir('/proc') if pid.isdigit ()]
for pid in pids:
else:
pids = [pid for pid in os.listdir('/proc') if pid.isdigit ()]
for pid in pids:
- result.append ((pid, open (os.path.join ('/proc', pid, 'comm'), 'rb').read ()
+ with open (os.path.join ('/proc', pid, 'cmdline'), 'rb') as p:
+ cmdline = p.read ().split ('\x00')
+ if len (cmdline) > 0:
+ result.append ((pid, cmdline[0]))
return result
def main ():
return result
def main ():
@@
-51,12
+59,20
@@
def main ():
gnunet_procs.append (p)
for p in gnunet_procs:
if re.match (r'gnunet-service-arm', p[1]):
gnunet_procs.append (p)
for p in gnunet_procs:
if re.match (r'gnunet-service-arm', p[1]):
- print ("killing arm {0:5} {1}".format (p[0], p[1]))
- os.kill (p[0], signal.SIGTERM)
+ print ("killing arm process {0:5} {1}".format (p[0], p[1]))
+ try:
+ terminate.safe_terminate_process_by_pid (int (p[0]), 1)
+ except OSError as e:
+ print ("failed: {0}".format (e))
+ pass
for p in gnunet_procs:
if not re.match (r'gnunet-service-arm', p[1]):
for p in gnunet_procs:
if not re.match (r'gnunet-service-arm', p[1]):
- print ("killing arm {0:5} {1}".format (p[0], p[1]))
- os.kill (p[0], signal.SIGTERM)
+ print ("killing non-arm process {0:5} {1}".format (p[0], p[1]))
+ try:
+ terminate.safe_terminate_process_by_pid (int (p[0]), 1)
+ except OSError as e:
+ print ("failed: {0}".format (e))
+ pass
if __name__ == '__main__':
if __name__ == '__main__':
- sys.exit (main ())
\ No newline at end of file
+ sys.exit (main ())