Is there a way to find processes that are “Not responding” using Terminal

activity-monitorcommand linemacosterminal

Activity Monitor can indicate processes that are Not responding:

Activity Monitor screenshot

Is there a way to find these processes using command line? Such as with ps, …

Best Answer

As far as I know, no such Terminal utility is included with macOS.

The standard tools such as ps interact with BSD-style processes on the POSIX layer. ps can tell you the state of the process such as the process being "dead", which means a process whose parent is not aware that it has completed running, or the process state being "uninterruptible waiting", which means a process that has asked the kernel to do something which it is waiting for.

Tools such as ps are not aware of whether or not processes are "responding" in the context that you have here. The "Not responding" label shown in Activity Monitor means that the application (not process, but application) is no longer processing events in its main GUI event loop (i.e. a Cocoa run loop).

I don't know of any third party utility that allows you to list the non-responding processes from the command line, so I decided to make one. You can download it from here:

https://github.com/jksoegaard/NonResponding

You can download the ready to use binary, or use Xcode to compile it on your own Mac.

Technical note: The program uses a "deprecated" function in order to obtain the information, we're looking for. That the function is deprecated does not mean that it doesn't work, or that it is as such problematic to use it right now. It means that the function will probably be removed from a future version of macOS. The function was deprecated in macOS 10.9, but so far no release version of macOS has a replacement for the function. The upcoming macOS Monterey (10.12) includes a new framework named MetricKit that has an alternative function for querying information about app responsiveness. When Monterey is released it could be possible to use this function instead (depending on what is included in the actual final release of Monterey).