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
Make it so that these can be used in other scripts by moving them from
functions defined in envsetup.sh to standalone scripts.
Test: stacks zygote64
Change-Id: I55ba76b248c54d9193fb019b7f4aca2f4c3a05bd