aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-02-24 20:49:39 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-02-24 20:49:39 +0100
commitb59b677c9b13483aac72b15f4f797863d841d958 (patch)
treeb27cf67eb450bfadb81688ae29ca7b298331f367
parent8972d067544e526b9f5d03b03985f0c902c074d2 (diff)
osmoutil: try to terminate process instead of killing
-rwxr-xr-xosmopy/osmoutil.py14
1 files changed, 12 insertions, 2 deletions
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 subprocess
import os
import sys
import importlib
+import time
"""Run a command, with stdout and stderr directed to devnull"""
@@ -36,9 +37,18 @@ If the process doesn't appear to exist (for instance, is None), do nothing"""
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."""