[PATCH 1/3] Shutdown the XVNC server when anaconda exits with an error

Martin Kolman mkolman at gmail.com
Thu Jun 13 14:40:20 UTC 2013


Signed-off-by: Martin Kolman <mkolman at gmail.com>
---
 anaconda          |  3 +++
 pyanaconda/vnc.py | 21 ++++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/anaconda b/anaconda
index 7962295..439e708 100755
--- a/anaconda
+++ b/anaconda
@@ -39,6 +39,9 @@ def exitHandler(rebootData, storage, exitCode=None):
     from pyanaconda import isys
     from pyanaconda.flags import flags
 
+    if flags.usevnc:
+        vnc.shutdownServer()
+
     if exitCode:
         anaconda.intf.shutdown()
 
diff --git a/pyanaconda/vnc.py b/pyanaconda/vnc.py
index ef008e5..301aa1e 100644
--- a/pyanaconda/vnc.py
+++ b/pyanaconda/vnc.py
@@ -36,6 +36,25 @@ import logging
 log = logging.getLogger("anaconda")
 stdoutLog = logging.getLogger("anaconda.stdout")
 
+XVNC_BINARY_NAME = "Xvnc"
+
+
+def shutdownServer():
+    """Try to shutdown any running XVNC server
+
+    Why is this function on the module level and not in the VncServer class ?
+
+    As the server needs to be killed from the exit handler, it would have
+    to somehow get to the VncServer instance. Like this, it can just kill
+    it by calling a function of the vnc module.
+    """
+    try:
+        iutil.execWithCapture("killall", [XVNC_BINARY_NAME])
+        log.info("The XVNC server has been shut down.")
+    except OSError as e:
+        log.error("Shutdown of the XVNC server failed with exception:\n%s" % e)
+
+
 class VncServer:
 
     def __init__(self, display="1", root="/", ip=None, name=None,
@@ -196,7 +215,7 @@ class VncServer:
             rc = self.setVNCPassword()
 
         # Lets start the xvnc.
-        xvnccommand =  [ "Xvnc", ":%s" % self.display,
+        xvnccommand =  [ XVNC_BINARY_NAME, ":%s" % self.display,
                         "-depth", "16", "-br",
                         "IdleTimeout=0", "-auth", "/dev/null", "-once",
                         "DisconnectClients=false", "desktop=%s" % (self.desktop,),
-- 
1.8.1.4



More information about the anaconda-patches mailing list