From 3c502ffaad7883772e7b6d7251edbea0c6d8a69f Mon Sep 17 00:00:00 2001 From: Chris Lumens Date: Fri, 7 Sep 2007 15:27:33 +0000 Subject: If the vnc server fails to start, log it and quit instead of silently continuing. --- vnc.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'vnc.py') diff --git a/vnc.py b/vnc.py index 74f3c0f05..9eeee5ff6 100644 --- a/vnc.py +++ b/vnc.py @@ -284,8 +284,25 @@ def startVNCServer(vncpassword="", root='/', vncconnecthost="", # oh well pass - os.execv(args[0], args) - sys.exit (1) + try: + os.execv(args[0], args) + sys.exit (1) + except OSError, e: + stdoutLog.critical("Error running %s: %s" % (root + "/usr/bin/Xvnc", e.strerror)) + sys.exit(1) + + # Wait for a bit, then make sure the VNC server really started before + # stating that it did. + time.sleep(1) + + try: + (pid, status) = os.waitpid(vncpid, os.WNOHANG) + except: + stdoutLog.critical("Could not start the VNC server. Aborting.") + sys.exit(1) + + if os.WIFEXITED(status) and os.WEXITSTATUS(status) > 0: + sys.exit(1) if vncpassword == "": stdoutLog.warning(_("\n\nWARNING!!! VNC server running with NO PASSWORD!\n" -- cgit