[gnome-shell] Only respawn if gnome-shell exits abnormally
- From: Owen Taylor <otaylor src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-shell] Only respawn if gnome-shell exits abnormally
- Date: Tue, 25 Aug 2009 23:02:03 +0000 (UTC)
commit af9ab5dbb665848e42c42e14984b04bed3f821ff
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Sun Aug 23 20:48:52 2009 -0400
Only respawn if gnome-shell exits abnormally
If Mutter exits with an exit status of 0, then that most likely
means that it was replaced by another window manager and we shoudln't
try to start the previous window manager and the panel.
(We don't actually know about the panel, but assume that if someone
is replacing us they know what they are doing.)
When Mutter exits with a signal, we know we want to restart.
When Mutter exits with a non-signal non-zero exit status, it's
ambiguous - we could be exiting because we lost the connection to
the X server, or because of a assertion failure in gnome-shell.
We assume the latter; if the X server is gone, all that will happen
is a bit of noise.
To know why Mutter exited accurately, we always wait() and
kill() the Mutter process, and then, if running in Xephyr, clean up
Xephyr afterwards. This has the nice side effect of exiting when
gnome-shell does and not forcing the user to close Xephyr manually.
http://bugzilla.gnome.org/show_bug.cgi?id=591171
src/gnome-shell.in | 37 +++++++++++++++++++++++++++++--------
1 files changed, 29 insertions(+), 8 deletions(-)
---
diff --git a/src/gnome-shell.in b/src/gnome-shell.in
index ebb0f39..ef15b95 100644
--- a/src/gnome-shell.in
+++ b/src/gnome-shell.in
@@ -268,13 +268,19 @@ if options.debug:
# later, in case we kill gdb at a bad time
termattrs = termios.tcgetattr(0);
+# We only respawn the previous environment on abnormal exit;
+# for a clean exit, we assume that gnome-shell was replaced with
+# something else.
+normal_exit = False
+
try:
if run_in_xephyr:
- shell = start_xephyr()
+ xephyr = start_xephyr()
# This makes us not grab the org.gnome.Panel name
os.environ['GNOME_SHELL_NO_REPLACE_PANEL'] = '1'
- start_shell()
+ shell = start_shell()
else:
+ xephyr = None
if gnome_panel_pid is not None:
kill_gnome_panel(gnome_panel_pid)
shell = start_shell()
@@ -283,8 +289,6 @@ try:
if options.verbose:
print "Waiting for shell to exit"
shell.wait()
- if options.verbose:
- print "Shell is dead"
except KeyboardInterrupt, e:
try:
@@ -292,14 +296,31 @@ except KeyboardInterrupt, e:
except:
pass
shell.wait()
- if options.verbose:
- print "Shell killed"
-
finally:
+ # Clean up Xephyr if it outlived the shell
+ if xephyr:
+ try:
+ os.kill(xephyr.pid, signal.SIGKILL)
+ except OSError:
+ pass
+
+ if shell.returncode == 0:
+ normal_exit = True
+ if options.verbose:
+ print "Shell exited normally"
+ elif shell.returncode < 0:
+ # Python has no mapping for strsignal; not worth using
+ # ctypes for this.
+ print "Shell killed with signal %d" % - shell.returncode
+ else:
+ # Normal reason here would be losing connection the X server
+ if options.verbose:
+ print "Shell exited with return code %d" % shell.returncode
+
if options.debug:
termios.tcsetattr(0, termios.TCSANOW, termattrs);
- if not run_in_xephyr:
+ if not run_in_xephyr and not normal_exit:
# Restart gnome-panel and window manager
# We don't want to start the new gnome-panel in the current
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]