Commit 362315d0 authored by v.putkinen's avatar v.putkinen Committed by Commit bot

telemetry: Fix runaway subprocess in monsoon_power_monitor.py

Telemetry leaves a memory hogging subprocess behind if:
1) A Monsoon Power Monitor is attached to host computer (Linux),
2) User runs a power-metric-using benchmark such as sunspider on Android
   ChromeShell, and
3) Benchmark raises an exception between power metric's Start and Stop
   calls. For example, an exception will occur if browser crashes and
   the benchmark does something like tab.WaitForJavaScriptExpression().

This patch fixes the issue by setting the daemon flag on the subprocess.
This will cause the main process to kill the subprocess on exit.

BUG=413596

R=ernstm@chromium.org

Review URL: https://codereview.chromium.org/572643002

Cr-Commit-Position: refs/heads/master@{#296177}
parent d1f5016c
...@@ -450,6 +450,7 @@ Victor Costan <costan@gmail.com> ...@@ -450,6 +450,7 @@ Victor Costan <costan@gmail.com>
Viet-Trung Luu <viettrungluu@gmail.com> Viet-Trung Luu <viettrungluu@gmail.com>
Vinay Anantharaman <vinaya@adobe.com> Vinay Anantharaman <vinaya@adobe.com>
Vipul Bhasin <vipul.bhasin@gmail.com> Vipul Bhasin <vipul.bhasin@gmail.com>
Visa Putkinen <v.putkinen@partner.samsung.com>
Vivek Galatage <vivek.vg@samsung.com> Vivek Galatage <vivek.vg@samsung.com>
Will Hirsch <chromium@willhirsch.co.uk> Will Hirsch <chromium@willhirsch.co.uk>
Xiang Long <xiang.long@intel.com> Xiang Long <xiang.long@intel.com>
......
...@@ -73,6 +73,8 @@ class MonsoonPowerMonitor(sysfs_power_monitor.SysfsPowerMonitor): ...@@ -73,6 +73,8 @@ class MonsoonPowerMonitor(sysfs_power_monitor.SysfsPowerMonitor):
args=(self._monsoon, args=(self._monsoon,
self._is_collecting, self._is_collecting,
self._powermonitor_output_file)) self._powermonitor_output_file))
# Ensure child is not left behind: parent kills daemonic children on exit.
self._powermonitor_process.daemon = True
self._powermonitor_process.start() self._powermonitor_process.start()
if not self._is_collecting.wait(timeout=0.5): if not self._is_collecting.wait(timeout=0.5):
self._powermonitor_process.terminate() self._powermonitor_process.terminate()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment