Você pode verificar se o pid está em execução e pertence ao seu aplicativo:
pid=$(< "$pidfile") # a bash builtin way to say: pid=$(cat $pidfile)
if kill -0 $pid &&
[[ -r /proc/$pid/cmdline ]] && # find the command line of this process
xargs -0l echo < /proc/$pid/cmdline | grep -q "your_program_name"
then
# your application is running
true
else
# no such running process, or some other program has acquired that pid:
# your pid file is out-of-date
rm "$pidfile"
fi