From f080bf1f7659c70f9208003fbbefc165d2fe46b8 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Mon, 23 Jul 2018 17:01:42 -0700 Subject: [PATCH] pid: switch to pgrep. Fix a bug where processes that didn't have a leading space from right justification of the pid column would return the process name instead of the pid, by switching to pgrep. Bug: http://b/111748205 Test: manual Change-Id: I3493474540ccfa89f5bb3e66153d9e96ec8bf1d9 --- scripts/pid | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/pid b/scripts/pid index a9f55d3e8..d78005e0d 100755 --- a/scripts/pid +++ b/scripts/pid @@ -28,12 +28,10 @@ fi if [ $EXACT == 1 ]; then PIDS="$(adb shell pidof $EXE)" - RC=$? else - PIDS=$(adb shell "ps -o PID,NAME | tail -n +1 | grep $EXE | tr -s ' ' | cut -f2 -d' '") - [ -n "$PIDS" ] - RC=$? + PIDS="$(adb shell pgrep -f $EXE)" fi +RC=$? for PID in $PIDS; do echo $PID