diff options
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/util.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py index d2e58bef2..cc7ce5b40 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -191,3 +191,12 @@ def ask_yes_no(question, default=False) -> bool: return False else: sys.stdout.write("Please respond with yes/y or no/n\n") + +def process_named_running(name): + """ Checks if process with given name is running and returns its PID. + If Process is not running, return None + """ + for p in psutil.process_iter(): + if name in p.name(): + return p.pid + return None |