Avoid traceback when bogus value in pidfile

This commit is contained in:
Erik Johnson 2017-12-12 17:09:03 -06:00
parent 465cacad83
commit d66f3a98d7
No known key found for this signature in database
GPG key ID: 5E5583C437808F3F

View file

@ -142,12 +142,12 @@ def get_pidfile(pidfile):
'''
Return the pid from a pidfile as an integer
'''
with salt.utils.fopen(pidfile) as pdf:
pid = pdf.read()
if pid:
try:
with salt.utils.fopen(pidfile) as pdf:
pid = pdf.read().strip()
return int(pid)
else:
return
except (OSError, IOError, TypeError, ValueError):
return None
def clean_proc(proc, wait_for_kill=10):