[Sugar-devel] [PATCH] sugar-emulator: don't clobber DISPLAY until X server starts

Bernie Innocenti bernie at codewiz.org
Mon May 24 02:54:52 EDT 2010


By switching $DISPLAY early upon launching a Xephyr instance,

In some concurrent scenarios, a Xephyr could die soon after starting
because the display is already taken by another instance. The emulator
diligently switches to the next display number and tries again,
however all subsequent attempts will fail because the DISPLAY
environment variable has already been set to the value of the failed
instance.

The fix consists in simply delaying setting $DISPLAY until we're sure
the X server is a good one.

Signed-off-by: Bernie Innocenti <bernie at codewiz.org>
---
 src/jarabe/util/emulator.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/jarabe/util/emulator.py b/src/jarabe/util/emulator.py
index 607d840..7005515 100644
--- a/src/jarabe/util/emulator.py
+++ b/src/jarabe/util/emulator.py
@@ -61,8 +61,6 @@ def _run_xephyr(display, dpi, dimensions, fullscreen):
 
     pipe = subprocess.Popen(cmd)
 
-    os.environ['DISPLAY'] = ":%d" % (display)
-    os.environ['SUGAR_EMULATOR_PID'] = str(pipe.pid)
     return pipe
 
 
@@ -90,6 +88,8 @@ def _start_xephyr(dpi, dimensions, fullscreen):
 
             for i_ in range(10):
                 if _check_server(display):
+                    os.environ['DISPLAY'] = ":%d" % (display)
+                    os.environ['SUGAR_EMULATOR_PID'] = str(pipe.pid)
                     return pipe
 
                 time.sleep(0.1)
-- 
1.7.0.1



More information about the Sugar-devel mailing list