From 35e0254622f8f099db3c7829cd61b85f6976c416 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 29 Mar 2020 15:46:12 +0200 Subject: 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(). --- python/vyos/util.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'python') 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)) -- cgit v1.2.3