* Stephen Hahn <sch at sun.com> [2007-06-28 13:28]:
>   Well, the most reliable way would be to have a monitoring framework of
>   some kind, that tested for liveness, rather than just existence.  That
>   contract duration is the default is based on our assessment of how
>   much software daemonizes.  If I were targetting an OpenSolaris OS with
>   smf(5) as a daemon author, I would seriously consider not daemonizing.

  Okay, I need to clarify that last part, since Dave and Dan came by to
  beat me up.  The best thing to do, as a daemon author, is to make your
  daemon's start-up precise:  the first process shouldn't exit until the
  second process has successfully started answering requests (or is
  otherwise performing its service).  There are a couple of examples:

  - daemonize_start() in svc.configd uses a pipe to send a "success
    byte" back to the parent:

    
http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/svc/configd/configd.c

  - main() in zoneadmd uses a semaphore in a shared page to coordinate
    parent and child (because they didn't want any open file descriptors
    to cross the zone boundary, I expect):

    
http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/zoneadmd/zoneadmd.c

  What I was too quickly commenting on is that I don't believe closing
  stdout/stderr are a part of daemonizing any longer--smf(5) would
  really like to capture and present diagnostic output your daemon emits
  to the administrator.

  - Stephen

-- 
sch at sun.com  http://blogs.sun.com/sch/

Reply via email to