Why write a script to monitor a daemon? Start it in /etc/ttys, it'll get restarted if it dies. Or use daemontools, I suppose. Of course, finding out *why* it is terminating would be preferred, ne?