My program(interphone_manager) has encountered a situation that when it is on WAN it's connection sometimes fail to connect to pjsip service. Then the program will quit. Thus I wrote a demons for restarting it when it smell interphone_manager's process doesn't exist.
The shell program is as follow.
#!/bin/sh
while true
do
ps -ef | grep "$PWD/resource/bin/interphone_manager" | grep -v "grep"
if [ "$?" -eq 1 ]
then
$PWD/interphone_manager
echo "process has been restart!"
else
echo "process already started!"
fi
sleep 3
done