[PATCH] python/osmo-python-tests[master]: osmoutil: try to terminate process instead of killing

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Feb 24 19:41:52 UTC 2017


Review at  https://gerrit.osmocom.org/1908

osmoutil: try to terminate process instead of killing

Change-Id: Iaa978467b140e3d6dc5a2a6d8966282e64630ce7
---
M osmopy/osmoutil.py
1 file changed, 12 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/08/1908/1

diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py
index bb03614..7b20043 100755
--- a/osmopy/osmoutil.py
+++ b/osmopy/osmoutil.py
@@ -18,6 +18,7 @@
 import os
 import sys
 import importlib
+import time
 
 
 """Run a command, with stdout and stderr directed to devnull"""
@@ -36,9 +37,18 @@
 
 
 def end_proc(proc):
-    if proc:
+    if not proc:
+        return
+
+    proc.terminate()
+    time.sleep(.1)
+    rc = proc.poll()
+    if rc is not None:
+        print "Terminated child process"
+    else:
         proc.kill()
-        proc.wait()
+        print "Killed child process"
+    proc.wait()
 
 
 """Add a directory to sys.path, try to import a config file."""

-- 
To view, visit https://gerrit.osmocom.org/1908
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaa978467b140e3d6dc5a2a6d8966282e64630ce7
Gerrit-PatchSet: 1
Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list