A question I have about both of these answers is what happens if the value being searched for i.e. $wanted appears in a field other than the pid field ?. If I understand the suggested code correctly the whole process table (including cpu,ctime,gid etc.. ) is being searched . Hence if the value appears in cpu instead of pid then it would still flag as having found the pid . Perhaps you could comment ?