1

I am using pgrep for a bunch of things, however I can't get pgrep to list if the process is defunct.

Running ps adds to the end of the item <defunct> but pgrep does not, is there anyway to do this?

3

pgrep is not able to filter a process based on its state. Try:

ps axo pid,stat | awk '$2 ~ /^Z/ { print $1 }'
  • Thanks very much @cuonglm - that's ok I don't want to filter it, I just needed to identify it. Is running ps on the pid's returned from grep the only way? The reason I was avoiding ps is because ps doesn't give process name, it only gives command. The -l of pgrep was what I was relying on. – Noitidart Feb 12 '16 at 8:49
  • 1
    @Noitidart: AFAICT, it's the only way, there's no stand alone standard tool to do the job. – cuonglm Feb 12 '16 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.