How can I determine if an application is not responding?

I have an application on OSX that repeatedly goes into a Not Responding state and has to be force killed. I was hoping to automate it, but when inspecting the process with ps I don't see anything that corresponds with the Not Responding state. I looked at the state indicator, but the app shows as S whether it is responding or not.

state 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'').

How can I determine if the process is Not Responding as the Activity Manager does?


I am open to AppleScript solutions as well.


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.


Here is an AppleScript using UI scripting that looks for a not responding process and kills them.

It will work with the Activity Monitor of Mavericks. But since this is UI scripting and since the UI of Activity Monitor changed, this will most likely not work with older OS X without some minor modifications.

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