From 91f544f227fb2dc25e6402a441f569e13df1d00d Mon Sep 17 00:00:00 2001 From: Shaju Mathew Date: Mon, 5 Dec 2022 20:02:49 -0800 Subject: [PATCH] Now ignoring adb shell service return error code in acov-llvm.py Bug: 261529166 Ignore failures when sending the flush signal. Some processes may have exited after we run `adb shell ps` but before we could send the flush signal. Test: Successful run of coverage metrics using acov-llvm (as documented in go/android-native-coverage-local-workflow Change-Id: I2fc0f71bf5f6d810b4124e28d7dd69ebfc2579b3 Signed-off-by: Shaju Mathew --- scripts/acov-llvm.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/acov-llvm.py b/scripts/acov-llvm.py index a6f35e34a..7c4d69adb 100755 --- a/scripts/acov-llvm.py +++ b/scripts/acov-llvm.py @@ -125,7 +125,15 @@ def send_flush_signal(pids=None): logging.warning( f'couldn\'t find any process with handler for signal 37') - adb_shell(['kill', '-37'] + pids) + # Some processes may have exited after we run `ps` command above - ignore failures when + # sending flush signal. + # We rely on kill(1) sending the signal to all pids on the command line even if some don't + # exist. This is true of toybox and "probably implied" by POSIX, even if not explicitly called + # out [https://pubs.opengroup.org/onlinepubs/9699919799/utilities/kill.html]. + try: + adb_shell(['kill', '-37'] + pids) + except subprocess.CalledProcessError: + logging.warning('Sending flush signal failed - some pids no longer active') def do_clean_device(args):