if(kill(pid,0)==0){//squid is running}else{ // no process
//unlink the pid file
}I don't know how kill is implemented in other operating systems but I'm sure that there is a way to check if process is running.
if(kill(pid,0)==0){//squid is running}else{ // no process
//unlink the pid file
}