Merge "Add --exact flag to pid
tool; new qpid
tool."
This commit is contained in:
commit
c86b05f807
1 changed files with 42 additions and 7 deletions
49
envsetup.sh
49
envsetup.sh
|
@ -774,15 +774,50 @@ function cproj()
|
|||
echo "can't find Android.mk"
|
||||
}
|
||||
|
||||
# simplified version of ps; output in the form
|
||||
# <pid> <procname>
|
||||
function qpid() {
|
||||
local prepend=''
|
||||
local append=''
|
||||
if [ "$1" = "--exact" ]; then
|
||||
prepend=' '
|
||||
append='$'
|
||||
shift
|
||||
elif [ "$1" = "--help" -o "$1" = "-h" ]; then
|
||||
echo "usage: qpid [[--exact] <process name|pid>"
|
||||
return 255
|
||||
fi
|
||||
|
||||
local EXE="$1"
|
||||
if [ "$EXE" ] ; then
|
||||
qpid | grep "$prepend$EXE$append"
|
||||
else
|
||||
adb shell ps \
|
||||
| tr -d '\r' \
|
||||
| sed -e 1d -e 's/^[^ ]* *\([0-9]*\).* \([^ ]*\)$/\1 \2/'
|
||||
fi
|
||||
}
|
||||
|
||||
function pid()
|
||||
{
|
||||
local EXE="$1"
|
||||
if [ "$EXE" ] ; then
|
||||
local PID=`adb shell ps | fgrep $1 | sed -e 's/[^ ]* *\([0-9]*\).*/\1/'`
|
||||
echo "$PID"
|
||||
else
|
||||
echo "usage: pid name"
|
||||
fi
|
||||
local prepend=''
|
||||
local append=''
|
||||
if [ "$1" = "--exact" ]; then
|
||||
prepend=' '
|
||||
append='$'
|
||||
shift
|
||||
fi
|
||||
local EXE="$1"
|
||||
if [ "$EXE" ] ; then
|
||||
local PID=`adb shell ps \
|
||||
| tr -d '\r' \
|
||||
| grep "$prepend$EXE$append" \
|
||||
| sed -e 's/^[^ ]* *\([0-9]*\).*$/\1/'`
|
||||
echo "$PID"
|
||||
else
|
||||
echo "usage: pid [--exact] <process name>"
|
||||
return 255
|
||||
fi
|
||||
}
|
||||
|
||||
# systemstack - dump the current stack trace of all threads in the system process
|
||||
|
|
Loading…
Reference in a new issue