1 diff --git a/third_party/android_testrunner/run_command.py b/third_party/android_testrunner/run_command.py
2 index d398daa..6b84156 100644
3 --- a/third_party/android_testrunner/run_command.py
4 +++ b/third_party/android_testrunner/run_command.py
13 @@ -80,31 +81,36 @@ def RunOnce(cmd, timeout_time=None, return_output=True, stdin_input=None):
15 start_time = time.time()
18 global _abort_on_error, error_occurred
19 error_occurred = False
22 + output_dest = tempfile.TemporaryFile(bufsize=0)
24 + # None means direct to stdout
27 + stdin_dest = subprocess.PIPE
30 + pipe = subprocess.Popen(
32 + executable='/bin/bash',
35 + stderr=subprocess.STDOUT,
36 + shell=True, close_fds=True,
37 + preexec_fn=lambda: signal.signal(signal.SIGPIPE, signal.SIG_DFL))
42 - output_dest = subprocess.PIPE
44 - # None means direct to stdout
47 - stdin_dest = subprocess.PIPE
50 - pipe = subprocess.Popen(
52 - executable='/bin/bash',
55 - stderr=subprocess.STDOUT,
57 - pid.append(pipe.pid)
59 - output = pipe.communicate(input=stdin_input)[0]
60 + pipe.communicate(input=stdin_input)
64 + output = output_dest.read()
66 if output is not None and len(output) > 0:
69 @@ -119,27 +125,17 @@ def RunOnce(cmd, timeout_time=None, return_output=True, stdin_input=None):
71 t = threading.Thread(target=Run)
75 - while not break_loop:
80 - if (not break_loop and timeout_time is not None
81 - and time.time() > start_time + timeout_time):
83 - os.kill(pid[0], signal.SIGKILL)
85 - # process already dead. No action required.
88 + t.join(timeout_time)
93 + # Can't kill a dead process.
96 logger.SilentLog("about to raise a timeout for: %s" % cmd)
97 raise errors.WaitForResponseTimedOutError
103 if _abort_on_error and error_occurred:
104 raise errors.AbortError(msg=output)