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: sys.stderr.write("Error spawning child '%s': %s\n" % (child_cmd, e)) child_reaper.set_children_pids(children_pids) # Check once after the mainloop is running, just in case the exit # conditions are satisfied before we even enter the main loop. # (Programming with unix the signal API sure is annoying.) def check_once(): child_reaper.check() return False # Only call once gobject.timeout_add(0, check_once) _cleanups.insert(0, app.cleanup) if app.run(): print("upgrading: not cleaning up Xvfb or socket") # Upgrading, so leave X server running # and don't delete the new socket (not ours) _cleanups.remove(kill_xvfb) _cleanups.remove(cleanup_socket) return 0
# 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).pid) except OSError, e: sys.stderr.write("Error spawning child '%s': %s\n" % (child_cmd, e)) child_reaper.set_children_pids(children_pids) # Check once after the mainloop is running, just in case the exit # conditions are satisfied before we even enter the main loop. # (Programming with unix the signal API sure is annoying.) def check_once(): child_reaper.check() return False # Only call once gobject.timeout_add(0, check_once) _cleanups.insert(0, app.cleanup) if app.run(): print("upgrading: not cleaning up Xvfb or socket") # Upgrading, so leave X server running # and don't delete the new socket (not ours) _cleanups.remove(kill_xvfb) _cleanups.remove(cleanup_socket) return 0
#disable ubuntu's global menu using env vars: env = os.environ.copy() if os.name=="posix": env["UBUNTU_MENUPROXY"] = "" env["QT_X11_NO_NATIVE_MENUBAR"] = "1" for child_cmd in opts.start_child: if child_cmd: try: proc = subprocess.Popen(child_cmd, env=env, shell=True, close_fds=True) children_pids[proc.pid] = child_cmd procs.append(proc) except OSError, e: sys.stderr.write("Error spawning child '%s': %s\n" % (child_cmd, e)) _cleanups.insert(0, app.cleanup) signal.signal(signal.SIGTERM, app.signal_quit) signal.signal(signal.SIGINT, app.signal_quit) try: e = app.run() except KeyboardInterrupt: e = 0 if e>0: log.info("upgrading: not cleaning up Xvfb or socket") # Upgrading, so leave X server running # and don't delete the new socket (not ours) if kill_xvfb in _cleanups: _cleanups.remove(kill_xvfb) _cleanups.remove(cleanup_socket) return 0