summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAles Kozumplik <akozumpl@redhat.com>2011-02-16 14:50:18 +0100
committerAles Kozumplik <akozumpl@redhat.com>2011-02-21 10:07:50 +0100
commit58e76d37ed8e55e4ac8f5e02febbc242a6a3bc4e (patch)
treeef0b694d50ded9310e11d728689ab2ff96f8df2d
parente3aa013ea43c93c00a0b8c3efced070c2fe6ca8b (diff)
Be better at handling killed metacity.
Resolves: rhbz#677605
-rwxr-xr-xanaconda36
-rw-r--r--pyanaconda/iutil.py14
2 files changed, 26 insertions, 24 deletions
diff --git a/anaconda b/anaconda
index f8bd5b260..43fc37eaa 100755
--- a/anaconda
+++ b/anaconda
@@ -44,20 +44,20 @@ def AnacondaShowWarning(message, category, filename, lineno, file=sys.stderr, li
def startMetacityWM():
childpid = os.fork()
if not childpid:
- cmd = '/usr/bin/metacity'
- if not os.access(cmd, os.X_OK):
- log.error("Unable to find the window manager binary.")
+ # after this point the method should never return (or throw an exception
+ # outside)
+ try:
+ args = ['--display', ':1',
+ '--sm-disable']
+ iutil.execWithRedirect('metacity', args,
+ stdout='/dev/null', stderr='/dev/null')
+ except BaseException as e:
+ # catch all possible exceptions
+ log.error("Problems running the window manager: %s" % str(e))
sys.exit(1)
- args = ['--display', ':1',
- '--sm-disable']
- rc = iutil.execWithRedirect(cmd, args,
- stdout='/dev/null', stderr='/dev/null')
- if rc:
- log.error("Error running window manager.")
- sys.exit (rc)
- else:
- log.info("The window manager has terminated.")
- sys.exit(0)
+
+ log.info("The window manager has terminated.")
+ sys.exit(0)
return childpid
def startAuditDaemon():
@@ -74,17 +74,13 @@ def startAuditDaemon():
# function to handle X startup special issues for anaconda
def doStartupX11Actions():
- global wm_pid
+ global wm_pid # pid of the anaconda fork where the window manager is running
setupGraphicalLinks()
# now start up the window manager
- try:
- wm_pid = startMetacityWM()
- log.info("Starting window manager, pid %s." % (wm_pid,))
- except Exception:
- wm_pid = None
- log.error("Unable to start the window manager.")
+ wm_pid = startMetacityWM()
+ log.info("Starting window manager, pid %s." % (wm_pid,))
if wm_pid is not None:
from pyanaconda import xutils
diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py
index 1e6e581ba..197bf1516 100644
--- a/pyanaconda/iutil.py
+++ b/pyanaconda/iutil.py
@@ -48,16 +48,22 @@ class ExecProduct(object):
#Python reimplementation of the shell tee process, so we can
#feed the pipe output into two places at the same time
class tee(threading.Thread):
- def __init__(self, inputdesc, outputdesc, logmethod):
+ def __init__(self, inputdesc, outputdesc, logmethod, command):
threading.Thread.__init__(self)
self.inputdesc = os.fdopen(inputdesc, "r")
self.outputdesc = outputdesc
self.logmethod = logmethod
self.running = True
+ self.command = command
def run(self):
while self.running:
- data = self.inputdesc.readline()
+ try:
+ data = self.inputdesc.readline()
+ except IOError:
+ self.logmethod("Can't read from pipe during a call to %s. "
+ "(program terminated suddenly?)" % self.command)
+ break
if data == "":
self.running = False
else:
@@ -122,8 +128,8 @@ def execWithRedirect(command, argv, stdin = None, stdout = None,
try:
#prepare tee proceses
- proc_std = tee(pstdout, stdout, program_log.info)
- proc_err = tee(perrout, stderr, program_log.error)
+ proc_std = tee(pstdout, stdout, program_log.info, command)
+ proc_err = tee(perrout, stderr, program_log.error, command)
#start monitoring the outputs
proc_std.start()