diff --git a/misc_funcs.py b/misc_funcs.py index 95f7b9f..0f6f60d 100644 --- a/misc_funcs.py +++ b/misc_funcs.py @@ -6,6 +6,9 @@ import svlgui from threading import Event, Thread import math +import subprocess +import re +import os def select_any(self): svlgui.MODE = " " @@ -66,6 +69,21 @@ def box(x, y, width, height, fill): return box +def process_exists(proc_name): + ps = subprocess.Popen("ps ax -o pid= -o args= ", shell=True, stdout=subprocess.PIPE) + ps_pid = ps.pid + output = ps.stdout.read() + ps.stdout.close() + ps.wait() + + for line in output.split("\n"): + res = re.findall("(\d+) (.*)", line) + if res: + pid = int(res[0][0]) + if proc_name in res[0][1] and pid != os.getpid() and pid != ps_pid: + return True + return False + def lastval(arr,index): for i in reversed(arr[:index]): if i: