Created
February 3, 2015 19:44
-
-
Save mem/7e989639e6204e687987 to your computer and use it in GitHub Desktop.
Look for process pid by command line without forking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
needle=/usr/lib/chromium/chromium | |
cd /proc | |
for pid in * ; do | |
if test -e "$pid/cmdline" ; then | |
read cmd rest < $pid/cmdline | |
if test "$cmd" = "$needle" ; then | |
echo $pid | |
fi | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment