"Application Not Responding" check

Is there a way to determine if an app (FileMaker) has locked up, and then force quit and relaunch that app if it has?

Thanks in advance.
Keith

You might be able to send a simple command to FMP to see if it responds. If it doesn’t, one might assume that it is frozen. I don’t know how to force quit an app but I suspect that a shell command might be required. This might serve as the framework for the script.

set v to ""
try
	tell application "FileMaker Pro" to set v to version
end try

if v is "" then
	-- force quit
end if

set exists_ to true
tell application "System Events"
	repeat until exists_ is false
		delay 2
		set exists_ to exists process "FileMaker Pro"
	end repeat
end tell

tell application "FileMaker Pro" to launch

– Rob

What if application dont return version information because it dont have AppleScript Dictionary?

I think Rob’s way of getting Filemaker to perform an action is a good way of testing if the app has locked up, as for Force Quit I have found that a shell script is very effective.

do shell script "kill_pid=`ps ax | grep FileMaker | grep -v grep | awk '{ print $1 }'`; kill $kill_pid"

tell application "FileMaker Pro" to activate

Ps seems to have a STATE column in its results.

If you look in the man page there is a list of STATES. Not sure if one of these indicates ‘Not RESPONDING’ as such.

set The_app to "FileMaker Pro"
tell application "System Events"
	try
		set pid to the unix id of process The_app as Unicode text
		
	end try
end tell
set state to paragraph 2 of (do shell script "ps -p " & quoted form of pid & "  | awk '{ print $3 }'")

I’ve looked through the man page for state and there’s a Z state that says “Marks a dead process (a ``zombie’').” or T that says “Marks a stopped process.”. I’m not sure if any of these states are present when FileMaker crashes but if you can replicate a crash and run Marks script then maybe you could do something like:

if state = "Z" then
do shell script "kill_pid=`ps ax | grep FileMaker | grep -v grep | awk '{ print $1 }'`; kill $kill_pid"

tell application "FileMaker Pro" to activate
end if 

You can just use the one script :slight_smile:

set The_app to "FileMaker Pro"
set state to ""
tell application "System Events"
	try
		set pid to the unix id of process The_app as Unicode text
		set state to paragraph 2 of (do shell script "ps -p " & quoted form of pid & "  | awk '{ print $3 }'")
	end try
end tell

if state = "Z" then
	do shell script "kill " & pid
	
	tell application The_app to activate
end if