I know I can do ps -aux | xargs kill etc but I want to list the PIDs of all tasks that are not responding (the red ones in Activity Monitor). What command I can execute in the terminal to list these red, non-responding tasks and auto terminate them.


Somebody has already asked pretty much the same question at How can I determine if an application is not responding? (determining which processes are not responding is the hard part, killing them is quite easy). I've quoted a relevant answer here:

The Not Responding state is not a process state, but rather the process has stopped communicating with the window manager / graphical engine. It could be tied up in a loop, hanging on a socket, remote file, anything that keeps it returning to the main loop that handles events. The window manager notices events are being queued up and thus labels it as "Not responding"

You may need to write a small X11 program that sends dummy events to the process, then kill it if it doesn't respond.

Thus, it's not exactly possible to determine which programs are not responding, at least not without heavily resorting on AppleScript/X11 logic.

If you're curious, this little snippet of AppleScript (made for Mavericks, probably won't work on anything else) was also posted on the linked thread and basically identifies all non-responding programs and then sends a KILL signal to them:

tell application "Activity Monitor" to run  --We need to run Activity Monitor
tell application "System Events" to tell process "Activity Monitor"
     tell radio button 1 of radio group 1 of group 1 of toolbar 1 of window 1 to click --Using the CPU View 
     tell outline 1 of scroll area 1 of window 1 -- working with the list 
         set notResponding to rows whose value of first static text contains "Not Responding" -- Looking for Not responding process
         repeat with aProcess in notResponding
             set pid to value of text field 5 of aProcess  -- For each non responding process retrieve the PID 
             if pid is not "" then do shell script ("kill -9 " & pid) -- KILL the PID. 
         end repeat
     end tell
end tell

However, if you've identified an application that is acting up, you can kill all instances of it with sudo killall [AppName], e.g. sudo killall "Activity Monitor". You can identify the PID of individual apps with pgrep [AppName], e.g. pgrep "Google Chrome", and you can kill any of the resulting PIDs with kill [PID].


A little late to the party but I've written a terminal application that will do this for you. It bypasses the need for UI scripting the Activity Monitor and instead uses a spindump report to determine the unresponsive processes and auto-terminates them for you.


  • Just tried it on Cataline. Compiling was fine but when running it, nothing really happens. It used 0,05 s of CPU time and that seems to be all. Any ideas why? – d-b Feb 9 '20 at 22:53

It is bugging me on my Jenkins OSX boxes where I seem to have something clogging up my systems on occasion. To be able to get better details on any problems. I will try this, hattip @coldlogic for the idea to use spindump!

    $ sudo spindump -notarget 5  -timelimit 60 -stdout -noFile  -noProcessingWhileSampling   -aggregateStacksByProcess | grep -B 8 "Unresponsive for"
Sampling all processes for 5 seconds with 10 milliseconds of run time between samples
Sampling completed, processing symbols...

Process:         System Preferences [31152]
Path:            /Applications/System Preferences.app/Contents/MacOS/System Preferences
Architecture:    x86_64
Parent:          launchd [1]
UID:             982457465
Task size:       38.81 MB (-20 KB)
CPU Time:        <0.001s (263.8K cycles, 65.8K instructions, 4.01c/i)
Note:            Unresponsive for 2258 seconds before sampling

Today I was able to repro causing Sys prefs to hang, so I was able to use it as a test. May this help future-me or someone else!

  • I just tried this on macOS 10.13.6, and it sprayed lots of data on (apparently) every running task. Perhaps this was macOS-version-specific? – Daniel Griscom Jun 24 '19 at 13:40

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.