From: Sascha Silbe <sascha@silbe.org>
Subject: [PATCH] sugar-emulator: kill X server on exit - 0.86 version (#1440)
If sugar aborts abnormally, the X server might keep running, so we should kill
it off after sugar returns.
This is the less invasive, but also less reliable version for 0.86.
Signed-off-by: Sascha Silbe <sascha@silbe.org>
---
bin/sugar-emulator | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/bin/sugar-emulator b/bin/sugar-emulator
index 7f06609..2e6497d 100644
a
|
b
|
|
17 | 17 | |
18 | 18 | import os |
19 | 19 | import random |
| 20 | import signal |
20 | 21 | import subprocess |
21 | 22 | import time |
22 | 23 | from optparse import OptionParser |
… |
… |
def _check_xephyr(display): |
69 | 70 | stderr=open(os.devnull, "w")) |
70 | 71 | return result == 0 |
71 | 72 | |
| 73 | |
| 74 | def _kill_xephyr(): |
| 75 | try: |
| 76 | os.kill(int(os.environ['SUGAR_EMULATOR_PID']), signal.SIGTERM) |
| 77 | except OSError: |
| 78 | return |
| 79 | |
| 80 | |
72 | 81 | def _start_xephyr(dpi, dimensions, fullscreen): |
73 | 82 | # FIXME evil workaround until F10 Xephyr is fixed |
74 | 83 | if os.path.exists('/etc/fedora-release'): |
… |
… |
def _start_xephyr(dpi, dimensions, fullscreen): |
88 | 97 | tries -= 1 |
89 | 98 | time.sleep(0.1) |
90 | 99 | |
| 100 | _kill_xephyr() |
| 101 | |
| 102 | |
91 | 103 | def _start_window_manager(): |
92 | 104 | cmd = ['metacity'] |
93 | 105 | |
… |
… |
def main(): |
151 | 163 | if options.scaling: |
152 | 164 | os.environ['SUGAR_SCALING'] = options.scaling |
153 | 165 | |
154 | | command = ['dbus-launch', 'dbus-launch', '--exit-with-session'] |
| 166 | command = ['dbus-launch', '--exit-with-session'] |
155 | 167 | |
156 | 168 | if not args: |
157 | 169 | command.append('sugar') |
… |
… |
def main(): |
162 | 174 | command.append('python') |
163 | 175 | |
164 | 176 | command.append(args[0]) |
165 | | |
166 | | os.execlp(*command) |
| 177 | |
| 178 | subprocess.call(command) |
| 179 | _kill_xephyr() |
| 180 | |
167 | 181 | |
168 | 182 | main() |