I have a binary program named as some thing like "mm.out". This program has some unexpected bugs and the bugs causes it to stop. I want to write a service or shell script to execute my binary again if it stopped unexpectedly. How should I write this program?
You should fix the program. But if you really want this, run it in a loop:
while ! mm.out
do
sleep 5 # Just in case the program dies immediately
done