Ticket #1440: sugar-1440-0.86.patch

File sugar-1440-0.86.patch, 1.9 KB (added by sascha_silbe, 15 years ago)

sugar-emulator: kill X server on exit - 0.86 version

  • bin/sugar-emulator

    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  
    1717
    1818import os
    1919import random
     20import signal
    2021import subprocess
    2122import time
    2223from optparse import OptionParser
    def _check_xephyr(display): 
    6970                             stderr=open(os.devnull, "w"))
    7071    return result == 0
    7172
     73
     74def _kill_xephyr():
     75    try:
     76        os.kill(int(os.environ['SUGAR_EMULATOR_PID']), signal.SIGTERM)
     77    except OSError:
     78        return
     79
     80
    7281def _start_xephyr(dpi, dimensions, fullscreen):
    7382    # FIXME evil workaround until F10 Xephyr is fixed
    7483    if os.path.exists('/etc/fedora-release'):
    def _start_xephyr(dpi, dimensions, fullscreen): 
    8897                    tries -= 1
    8998                    time.sleep(0.1)
    9099
     100            _kill_xephyr()
     101
     102
    91103def _start_window_manager():
    92104    cmd = ['metacity']
    93105
    def main(): 
    151163    if options.scaling:
    152164        os.environ['SUGAR_SCALING'] = options.scaling
    153165
    154     command = ['dbus-launch', 'dbus-launch', '--exit-with-session']
     166    command = ['dbus-launch', '--exit-with-session']
    155167
    156168    if not args:
    157169        command.append('sugar')
    def main(): 
    162174            command.append('python')
    163175
    164176        command.append(args[0])
    165    
    166     os.execlp(*command)
     177
     178    subprocess.call(command)
     179    _kill_xephyr()
     180
    167181
    168182main()