#!/bin/sh[Editor's note: the "while" command just inside the first 'do' loop has been broken onto two lines for easier readability. Put a space after "aux" and then everything from line two onto the same line.]
while true
do
while [ `ps -aux | grep 'Dock.app' | grep -v 'grep' | wc -l` = 1 -a `ps -aux
| grep 'Finder.app' | grep -v 'grep' | wc -l` = 0 ]
do
sleep 1
done
/Applications/OSXvnc.app/Contents/MacOS/OSXvnc-server `cat /etc/osxvnc-args`
sleep 10
done
What it does is check to see if Dock is running but Finder isn't (this happens when you are installing software that requires closing everything) and if so, waits for this to change. Once it runs, if it gets killed for any reason, it waits 10 seconds and starts checking again. The 10 second wait was necessary since momentarily after killing OSXvnc, both Dock and Finder are still running (finder hasn't been killed), and OSXvnc will start up again and get in the weird loop again.
I got frustrated and created this when that mysterious loop cuased me to force boot one too many times and it corrupted my FS... :( now I don't have to worry about it :)
Hope someone else finds this useful.

