diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py index f5f033fa..7cfc3b1d 100644 --- a/test/pacman/pmtest.py +++ b/test/pacman/pmtest.py @@ -232,7 +232,7 @@ class pmtest(object): return files def run(self, pacman): - if os.path.isfile(util.PM_LOCK): + if util.ispacmanlocked(): tap.bail("\tERROR: another pacman session is on-going -- skipping") return diff --git a/test/pacman/util.py b/test/pacman/util.py index ee844812..e5de4b81 100644 --- a/test/pacman/util.py +++ b/test/pacman/util.py @@ -184,3 +184,15 @@ def mkdir(path): elif os.path.isfile(path): raise OSError("'%s' already exists and is not a directory" % path) os.makedirs(path, 0o755) + +# +# Locking +# +def ispacmanlocked(): + if not os.path.exists(PM_LOCK): + return False + + with open(PM_LOCK, 'r') as f: + pid = f.read().strip() + + return pid.isdigit() and os.path.exists(f'/proc/{pid}')