Просмотр исходного кода

Restart manager after installing update

Agnieszka Kostrzewa 12 лет назад
Родитель
Сommit
a974f10435
2 измененных файлов с 9 добавлено и 1 удалено
  1. 8 1
      qubesmanager/main.py
  2. 1 0
      rpm_spec/qmgr.spec

+ 8 - 1
qubesmanager/main.py

@@ -22,6 +22,7 @@
 
 import sys
 import os
+import signal
 import fcntl
 import errno
 import dbus
@@ -1825,6 +1826,8 @@ def handle_exception( exc_type, exc_value, exc_traceback ):
     
     msg_box.exec_()
 
+def sighup_handler(signum, frame):
+    os.execl("/usr/bin/qubes-manager")
 
 def main():
 
@@ -1832,7 +1835,9 @@ def main():
     # Avoid starting more than one instance of the app
     lock = QubesDaemonPidfile ("qubes-manager")
     if lock.pidfile_exists():
-        if lock.pidfile_is_stale():
+        if lock.read_pid() == os.getpid():
+            pass
+        elif lock.pidfile_is_stale():
             lock.remove_pidfile()
             print "Removed stale pidfile (has the previous daemon instance crashed?)."
         else:
@@ -1840,6 +1845,8 @@ def main():
 
     lock.create_pidfile()
 
+    signal.signal(signal.SIGHUP, sighup_handler)
+
     global qubes_host
     qubes_host = QubesHost()
 

+ 1 - 0
rpm_spec/qmgr.spec

@@ -67,6 +67,7 @@ cp qubes-manager.desktop $RPM_BUILD_ROOT/etc/xdg/autostart/
 
 %post
 update-desktop-database &> /dev/null || :
+killall -1 qubes-manager
 
 %postun
 update-desktop-database &> /dev/null || :