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

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

Issue 635953002: Linux Chromoting: Explicitly kill all child processes on termination. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Send SIGKILL after timeout Created 6 years, 2 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 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 # Close the temporary file-descriptors. 773 # Close the temporary file-descriptors.
774 os.close(devnull_fd) 774 os.close(devnull_fd)
775 os.close(log_fd) 775 os.close(log_fd)
776 776
777 777
778 def cleanup(): 778 def cleanup():
779 logging.info("Cleanup.") 779 logging.info("Cleanup.")
780 780
781 global g_desktops 781 global g_desktops
782 for desktop in g_desktops: 782 for desktop in g_desktops:
783 if desktop.x_proc: 783 for proc, name in [(desktop.x_proc, "Xvfb"),
784 logging.info("Terminating Xvfb") 784 (desktop.session_proc, "session"),
785 desktop.x_proc.terminate() 785 (desktop.host_proc, "host")]:
786 if proc is not None:
787 logging.info("Terminating " + name)
788 try:
789 psutil_proc = psutil.Process(proc.pid)
790 psutil_proc.terminate()
791
792 # Use a short timeout, to avoid delaying service shutdown if the
793 # process refuses to die for some reason.
794 psutil_proc.wait(timeout=10)
rmsousa 2014/10/10 00:50:27 This will serialize the process terminations on th
Lambros 2014/10/10 01:12:15 Nice idea, but probably too complicated to be wort
795 except psutil.TimeoutExpired:
796 logging.error("Timed out - sending SIGKILL")
797 psutil_proc.kill()
798 except psutil.Error:
799 logging.error("Error terminating process")
800
786 g_desktops = [] 801 g_desktops = []
787 if ParentProcessLogger.instance(): 802 if ParentProcessLogger.instance():
788 ParentProcessLogger.instance().release_parent() 803 ParentProcessLogger.instance().release_parent()
789 804
790 class SignalHandler: 805 class SignalHandler:
791 """Reload the config file on SIGHUP. Since we pass the configuration to the 806 """Reload the config file on SIGHUP. Since we pass the configuration to the
792 host processes via stdin, they can't reload it, so terminate them. They will 807 host processes via stdin, they can't reload it, so terminate them. They will
793 be relaunched automatically with the new config.""" 808 be relaunched automatically with the new config."""
794 809
795 def __init__(self, host_config): 810 def __init__(self, host_config):
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 else: 1252 else:
1238 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) 1253 logging.info("Host exited with status %s." % os.WEXITSTATUS(status))
1239 elif os.WIFSIGNALED(status): 1254 elif os.WIFSIGNALED(status):
1240 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) 1255 logging.info("Host terminated by signal %s." % os.WTERMSIG(status))
1241 1256
1242 1257
1243 if __name__ == "__main__": 1258 if __name__ == "__main__":
1244 logging.basicConfig(level=logging.DEBUG, 1259 logging.basicConfig(level=logging.DEBUG,
1245 format="%(asctime)s:%(levelname)s:%(message)s") 1260 format="%(asctime)s:%(levelname)s:%(message)s")
1246 sys.exit(main()) 1261 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