core: Provide more meaningful error when failed to kill old QubesDB instance

This process may be running as root in case of default NetVM. But do not
kill it forcibly (through sudo or so), because it may also be stale
pid file. After all, QubesDB should automatically terminate when its VM
is terminated, so this code is already some error handling.

Fixes QubesOS/qubes-issues#1331
This commit is contained in:
Marek Marczykowski-Górecki 2015-10-13 23:46:59 +02:00
parent 2b7bd1f1f5
commit 5c549e1134
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -1738,7 +1738,15 @@ class QubesVm(object):
try:
if os.path.exists(pidfile):
old_qubesdb_pid = open(pidfile, 'r').read()
os.kill(int(old_qubesdb_pid), signal.SIGTERM)
try:
os.kill(int(old_qubesdb_pid), signal.SIGTERM)
except OSError:
raise QubesException(
"Failed to kill old QubesDB instance (PID {}). "
"Terminate it manually and retry. "
"If that isn't QubesDB process, "
"remove the pidfile: {}".format(old_qubesdb_pid,
pidfile))
timeout = 25
while os.path.exists(pidfile) and timeout:
time.sleep(0.2)