List hung processes in Terminal

terminal

Is there any way to list only those processes which are hung, i.e., "not responding", in Terminal?

The only way I know to do this is look in Activity Monitor for the ones in red.

Best Answer

You can use the following command:

ps aux | grep -w Z

From ps man page:

The state is given by a sequence of characters, for example, ``RWNA''.
The first character indicates the run state of the process:

I       Marks a process that is idle (sleeping for longer than about 20 seconds).
R       Marks a runnable process.
S       Marks a process that is sleeping for less than about 20 seconds.
T       Marks a stopped process.
U       Marks a process in uninterruptible wait.
Z       Marks a dead process (a ``zombie'').