If you want to script this yourself you could check the PID file Squid uses when it runs, check if it exists and if it does cat it and save the PID to a variable. Then notice the full commandline Squid runs as, use that in pgrep -f 'commandline' and save the PID(

to an array. Check if the array is empty ("${#array[@]}"), else compare PIDs. If empty or PIDs not matching up, stop Squid gracefully, remove the PID file then start Squid.
OTOH running a dedicated process watcher like Monit is easy to configure and expand, faster in checking and more versatile as it can start, restart about any service and alert you all in one go and all of the time.