Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: remoting/host/linux/linux_me2me_host.py

Issue 1138613002: Handle exception writing to Chromoting host's stdin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 ParentProcessLogger.instance().release_parent() 502 ParentProcessLogger.instance().release_parent()
503 503
504 signal.signal(signal.SIGUSR1, sigusr1_handler) 504 signal.signal(signal.SIGUSR1, sigusr1_handler)
505 args.append("--signal-parent") 505 args.append("--signal-parent")
506 506
507 self.host_proc = subprocess.Popen(args, env=self.child_env, 507 self.host_proc = subprocess.Popen(args, env=self.child_env,
508 stdin=subprocess.PIPE) 508 stdin=subprocess.PIPE)
509 logging.info(args) 509 logging.info(args)
510 if not self.host_proc.pid: 510 if not self.host_proc.pid:
511 raise Exception("Could not start Chrome Remote Desktop host") 511 raise Exception("Could not start Chrome Remote Desktop host")
512 self.host_proc.stdin.write(json.dumps(host_config.data)) 512
513 self.host_proc.stdin.close() 513 try:
514 self.host_proc.stdin.write(json.dumps(host_config.data))
515 self.host_proc.stdin.flush()
516 except IOError as e:
517 # This can occur in rare situations, for example, if the machine is
518 # heavily loaded and the host process dies quickly (maybe if the X
519 # connection failed), the host process might be gone before this code
520 # writes to the host's stdin. Catch and log the exception, allowing
521 # the process to be retried instead of exiting the script completely.
522 logging.error("Failed writing to host's stdin: " + str(e))
523 finally:
524 self.host_proc.stdin.close()
514 525
515 526
516 def get_daemon_proc(): 527 def get_daemon_proc():
517 """Checks if there is already an instance of this script running, and returns 528 """Checks if there is already an instance of this script running, and returns
518 a psutil.Process instance for it. 529 a psutil.Process instance for it.
519 530
520 Returns: 531 Returns:
521 A Process instance for the existing daemon process, or None if the daemon 532 A Process instance for the existing daemon process, or None if the daemon
522 is not running. 533 is not running.
523 """ 534 """
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 else: 1353 else:
1343 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) 1354 logging.info("Host exited with status %s." % os.WEXITSTATUS(status))
1344 elif os.WIFSIGNALED(status): 1355 elif os.WIFSIGNALED(status):
1345 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) 1356 logging.info("Host terminated by signal %s." % os.WTERMSIG(status))
1346 1357
1347 1358
1348 if __name__ == "__main__": 1359 if __name__ == "__main__":
1349 logging.basicConfig(level=logging.DEBUG, 1360 logging.basicConfig(level=logging.DEBUG,
1350 format="%(asctime)s:%(levelname)s:%(message)s") 1361 format="%(asctime)s:%(levelname)s:%(message)s")
1351 sys.exit(main()) 1362 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698