| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Virtual Me2Me implementation. This script runs and manages the processes | 6 # Virtual Me2Me implementation. This script runs and manages the processes |
| 7 # required for a Virtual Me2Me desktop, which are: X server, X desktop | 7 # required for a Virtual Me2Me desktop, which are: X server, X desktop |
| 8 # session, and Host process. | 8 # session, and Host process. |
| 9 # This script is intended to run continuously as a background daemon | 9 # This script is intended to run continuously as a background daemon |
| 10 # process, running under an ordinary (non-root) user account. | 10 # process, running under an ordinary (non-root) user account. |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 if retcode == 0: | 247 if retcode == 0: |
| 248 break | 248 break |
| 249 time.sleep(0.5) | 249 time.sleep(0.5) |
| 250 if retcode != 0: | 250 if retcode != 0: |
| 251 raise Exception("Could not connect to Xvfb.") | 251 raise Exception("Could not connect to Xvfb.") |
| 252 else: | 252 else: |
| 253 logging.info("Xvfb is active.") | 253 logging.info("Xvfb is active.") |
| 254 | 254 |
| 255 def launch_x_session(self): | 255 def launch_x_session(self): |
| 256 # Start desktop session | 256 # Start desktop session |
| 257 # The /dev/null input redirection is necessary to prevent Xsession from |
| 258 # reading from stdin. If this code runs as a shell background job in a |
| 259 # terminal, any reading from stdin causes the job to be suspended. |
| 260 # Daemonization would solve this problem by separating the process from the |
| 261 # controlling terminal. |
| 257 session_proc = subprocess.Popen("/etc/X11/Xsession", | 262 session_proc = subprocess.Popen("/etc/X11/Xsession", |
| 263 stdin=open("/dev/null", "r"), |
| 258 cwd=os.environ["HOME"], | 264 cwd=os.environ["HOME"], |
| 259 env=self.child_env) | 265 env=self.child_env) |
| 260 if not session_proc.pid: | 266 if not session_proc.pid: |
| 261 raise Exception("Could not start X session") | 267 raise Exception("Could not start X session") |
| 262 | 268 |
| 263 def launch_host(self): | 269 def launch_host(self): |
| 264 # Start remoting host | 270 # Start remoting host |
| 265 command = locate_executable(REMOTING_COMMAND) | 271 command = locate_executable(REMOTING_COMMAND) |
| 266 self.host_proc = subprocess.Popen(command, env=self.child_env) | 272 self.host_proc = subprocess.Popen(command, env=self.child_env) |
| 267 if not self.host_proc.pid: | 273 if not self.host_proc.pid: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 logging.info("X server process terminated with code %d", status) | 314 logging.info("X server process terminated with code %d", status) |
| 309 break | 315 break |
| 310 | 316 |
| 311 if pid == desktop.host_proc.pid: | 317 if pid == desktop.host_proc.pid: |
| 312 logging.info("Host process terminated, relaunching") | 318 logging.info("Host process terminated, relaunching") |
| 313 desktop.launch_host() | 319 desktop.launch_host() |
| 314 | 320 |
| 315 if __name__ == "__main__": | 321 if __name__ == "__main__": |
| 316 logging.basicConfig(level=logging.DEBUG) | 322 logging.basicConfig(level=logging.DEBUG) |
| 317 sys.exit(main()) | 323 sys.exit(main()) |
| OLD | NEW |