예제 #1
0
파일: server.py 프로젝트: rudresh2319/Xpra
    def kill_xvfb():
        # Close our display(s) first, so the server dying won't kill us.
        print("killing xvfb with pid %s" % xvfb_pid)
        for display in gtk.gdk.display_manager_get().list_displays():
            display.close()
        os.kill(xvfb_pid, signal.SIGTERM)

    if xvfb_pid is not None and not opts.use_display:
        _cleanups.append(kill_xvfb)

    from xpra.server import can_run_server, XpraServer
    if not can_run_server():
        return 1

    # This import is delayed because the module depends on gtk:
    app = XpraServer(clobber, sockets, opts)

    child_reaper = ChildReaper(app, opts.exit_with_children)
    # Always register the child reaper, because even if exit_with_children is
    # false, we still need to reap them somehow to avoid zombies:
    signal.signal(signal.SIGCHLD, child_reaper)
    if opts.exit_with_children:
        assert opts.children
    if opts.children:
        children_pids = set()
        for child_cmd in opts.children:
            try:
                children_pids.add(
                    subprocess.Popen(child_cmd, shell=True,
                                     close_fds=True).pid)
            except OSError, e: