mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-14 19:05:37 +00:00
Merge pull request #9572 from LabNConsulting/chopps/fix-cleanup
tests: deal with parallel exit of process we are reaping
This commit is contained in:
commit
75ec7bdb5d
@ -33,16 +33,22 @@ def get_pids_with_env(has_var, has_val=None):
|
|||||||
result = {}
|
result = {}
|
||||||
for pidenv in glob.iglob("/proc/*/environ"):
|
for pidenv in glob.iglob("/proc/*/environ"):
|
||||||
pid = pidenv.split("/")[2]
|
pid = pidenv.split("/")[2]
|
||||||
with open(pidenv, "rb") as rfb:
|
try:
|
||||||
envlist = [x.decode("utf-8").split("=", 1) for x in rfb.read().split(b"\0")]
|
with open(pidenv, "rb") as rfb:
|
||||||
envlist = [[x[0], ""] if len(x) == 1 else x for x in envlist]
|
envlist = [
|
||||||
envdict = dict(envlist)
|
x.decode("utf-8").split("=", 1) for x in rfb.read().split(b"\0")
|
||||||
if has_var not in envdict:
|
]
|
||||||
continue
|
envlist = [[x[0], ""] if len(x) == 1 else x for x in envlist]
|
||||||
if has_val is None:
|
envdict = dict(envlist)
|
||||||
result[pid] = envdict
|
if has_var not in envdict:
|
||||||
elif envdict[has_var] == str(has_val):
|
continue
|
||||||
result[pid] = envdict
|
if has_val is None:
|
||||||
|
result[pid] = envdict
|
||||||
|
elif envdict[has_var] == str(has_val):
|
||||||
|
result[pid] = envdict
|
||||||
|
except Exception:
|
||||||
|
# E.g., process exited and files are gone
|
||||||
|
pass
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user