summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-03-29 15:46:12 +0200
committerChristian Poessinger <christian@poessinger.com>2020-03-29 15:46:12 +0200
commit35e0254622f8f099db3c7829cd61b85f6976c416 (patch)
tree77014e7562e26edf4f0561a79c72babcdf52df14 /python
parent552106b0fb27003e5e5be5494f2213f54a699b9e (diff)
downloadvyos-1x-35e0254622f8f099db3c7829cd61b85f6976c416.tar.gz
vyos-1x-35e0254622f8f099db3c7829cd61b85f6976c416.zip
vyos.util: increase usage of process_running() and remove duplicated code
OpenVPN, WIFI, SSTP all had the same boiler plate copied about checking if a process associated with a pidfile is running or not. This has been migrated to the common library function vyos.util.process_running().
Diffstat (limited to 'python')
-rw-r--r--python/vyos/util.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 635b11ee5..67aa87a3a 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -84,6 +84,8 @@ def colon_separated_to_dict(data_string, uniquekeys=False):
def process_running(pid_file):
""" Checks if a process with PID in pid_file is running """
+ if not os.path.isfile(pid_file):
+ return False
with open(pid_file, 'r') as f:
pid = f.read().strip()
return psutil.pid_exists(int(pid))