Thomas Christian Chust wrote:

I wonder why one would want to pass this cleanup argument to the daemon
procedure -- why should the spawned process simply perform cleanup once
the daemon procedure returns?

The problem with that, as I see it, is that sometimes daemons don't get to return normally, i.e. if they get killed. Of course any proper daemon will implement signal handlers and such so that it will clean up after itself and exit gracefully. With my implementation you can implement that sort of stuff anyway you like, and just call the additional (cleanup) proc to take care of whatever you had daemonize set up for you, i.e. the PID file.

Of course, it might be nice to have daemonize take care of everything, including signal handlers and such. I would see that as a further abstraction.

(define (super-daemonize proc)
  (daemonize (lambda (cleanup)
               (set-signal-handler! ...) ; Call cleanup if we get killed.
               (proc)
               (cleanup))))



_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to