Index: scripts/slave/recipe_modules/chromium_android/resources/shutdown_device_temp_monitor.py |
diff --git a/scripts/slave/recipe_modules/chromium_android/resources/shutdown_device_temp_monitor.py b/scripts/slave/recipe_modules/chromium_android/resources/shutdown_device_temp_monitor.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..417c9f4e8b5ecba4557c94b29995a6dc40651492 |
--- /dev/null |
+++ b/scripts/slave/recipe_modules/chromium_android/resources/shutdown_device_temp_monitor.py |
@@ -0,0 +1,27 @@ |
+#!/usr/bin/env python |
+ |
+""" |
+Shutdown the device_temp_monitor process launched |
+by spawn_device_temp_monitor.py by reading its pid in the file pid_file_path. |
+""" |
+ |
+import logging |
+import os |
+import signal |
+import sys |
+ |
+def main(pid_file_path='/tmp/device_monitor_pid'): |
luqui
2015/09/03 01:10:41
pidfiles usually end in .pid, rather than _pid.
jbudorick
2015/09/03 17:37:31
I'd use argparse for command-line arguments to a s
|
+ |
+ try: |
+ with open(pid_file_path) as pid_file: |
+ monitor_pid = int(pid_file.readline()) |
+ |
+ logging.info('Sending SIGTERM to %d', monitor_pid) |
+ os.kill(monitor_pid, signal.SIGTERM) |
+ os.remove(pid_file_path) |
luqui
2015/09/03 01:10:41
I think it should clean up its own pidfile with a
|
+ |
+ except (IOError, OSError): |
+ logging.exception('Error terminating device monitor') |
+ |
+if __name__ == '__main__': |
+ sys.exit(main(*sys.argv[1:])) |