From 5c549e1134d1635f6eef1abaac774e0da37d93b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 13 Oct 2015 23:46:59 +0200 Subject: [PATCH] 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 --- core-modules/000QubesVm.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core-modules/000QubesVm.py b/core-modules/000QubesVm.py index 219690fb..fbca1f15 100644 --- a/core-modules/000QubesVm.py +++ b/core-modules/000QubesVm.py @@ -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)