in reply to Tracking process daemons

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, refork 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.

Replies are listed 'Best First'.
(tye)Re: Tracking process daemons
by tye (Sage) on Mar 19, 2001 at 21:41 UTC

    Note that you can do this same trick under Win32 if you substitute a socket for the pipe (well, and I wouldn't suggest using fork directly for either case).

            - tye (but my friends call me "Tye")