Return int(-1) when pidfile contains invalid data

This commit is contained in:
twangboy 2018-03-29 16:59:52 -06:00
parent 395b7f8fdc
commit 49b3e937da
No known key found for this signature in database
GPG key ID: 93FF3BDEB278C9EB
2 changed files with 4 additions and 3 deletions

View file

@ -35,6 +35,7 @@ import salt.utils.args
import salt.utils.xdg
import salt.utils.jid
import salt.utils.files
import salt.utils.win_functions
from salt.utils import kinds
from salt.defaults import DEFAULT_TARGET_DELIM
from salt.utils.validate.path import is_writeable
@ -1020,8 +1021,8 @@ class DaemonMixIn(six.with_metaclass(MixInMeta, object)):
if self.check_pidfile() and self.is_daemonized(pid) and not os.getppid() == pid:
return True
else:
# We have no os.getppid() on Windows. Best effort.
if self.check_pidfile() and self.is_daemonized(pid):
# We have no os.getppid() on Windows. Use salt.utils.win_functions.get_parent_pid
if self.check_pidfile() and self.is_daemonized(pid) and not salt.utils.win_functions.get_parent_pid() == pid:
return True
return False

View file

@ -147,7 +147,7 @@ def get_pidfile(pidfile):
pid = pdf.read().strip()
return int(pid)
except (OSError, IOError, TypeError, ValueError):
return None
return int(-1)
def clean_proc(proc, wait_for_kill=10):