summaryrefslogtreecommitdiff
path: root/tools/patman/cros_subprocess.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/patman/cros_subprocess.py')
-rw-r--r--tools/patman/cros_subprocess.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/patman/cros_subprocess.py b/tools/patman/cros_subprocess.py
index fdd5138685..88a4693fef 100644
--- a/tools/patman/cros_subprocess.py
+++ b/tools/patman/cros_subprocess.py
@@ -128,6 +128,9 @@ class Popen(subprocess.Popen):
sys.stdout or sys.stderr.
data: a string containing the data
+ Returns:
+ True to terminate the process
+
Note: The data read is buffered in memory, so do not use this
method if the data size is large or unlimited.
@@ -175,6 +178,7 @@ class Popen(subprocess.Popen):
stderr = bytearray()
combined = bytearray()
+ stop_now = False
input_offset = 0
while read_set or write_set:
try:
@@ -212,7 +216,7 @@ class Popen(subprocess.Popen):
stdout += data
combined += data
if output:
- output(sys.stdout, data)
+ stop_now = output(sys.stdout, data)
if self.stderr in rlist:
data = b''
# We will get an error on read if the pty is closed
@@ -227,7 +231,9 @@ class Popen(subprocess.Popen):
stderr += data
combined += data
if output:
- output(sys.stderr, data)
+ stop_now = output(sys.stderr, data)
+ if stop_now:
+ self.terminate()
# All data exchanged. Translate lists into strings.
stdout = self.ConvertData(stdout)