There is a horrendously simple way to do this under UNIX. Let the watchdog process fork the daemon with a full-duplex pipe (or two half-duplex pipes). Let one get the read end and the other the write end. At the beginning of each program,
select the handles for reading/writing (appropriately) but don't send anything on the pipes. If your select ever returns values during the process (you could even use asynchronous
IO to skip threading- just DON'T POLL!!!), you know the other is down and an error has occcured somewhere. This way you have the watchdog watching the daemon and the daemon watching the watchdog. If the daemon fails, re
fork it and log the error. If watchdog fails, log the error and cleanly quit the daemon. Obviously, it becomes
extremely important to have a bug-free, non-
deprecated watchdog. Good luck!
AgentM Systems nor Nasca Enterprises nor
Bone::Easy nor Macperl is responsible for the
comments made by
AgentM. Remember, you can build any logical system with NOR.