fix crash when stopping/restarting with an invalid pidfile

in node directory
This commit is contained in:
Lukas Pirl 2017-08-23 20:23:15 +02:00
parent 04fc0e43f7
commit dd9b951c4b

View File

@ -185,7 +185,16 @@ def stop(config):
return 2
with open(pidfile, "r") as f:
pid = f.read()
pid = int(pid)
try:
pid = int(pid)
except ValueError:
# The error message below mimics a Twisted error message, which is
# displayed when starting a node with an invalid pidfile.
print >>err, "Pidfile %s contains non-numeric value" % pidfile
# we define rc=2 to mean "nothing is running, but it wasn't me who
# stopped it"
return 2
# kill it hard (SIGKILL), delete the twistd.pid file, then wait for the
# process itself to go away. If it hasn't gone away after 20 seconds, warn