[tor-dev] start_daemon and finish_daemon

Nick Mathewson nickm at alum.mit.edu
Thu Jun 14 01:52:52 UTC 2012


On Wed, Jun 13, 2012 at 7:26 PM, Zack Weinberg <zackw at panix.com> wrote:
> Why is the process of going into daemon mode (on Unix) split into two
> functions, start_daemon and finish_daemon?

It's been so long since we added that code; I hope I remember.

If I've got it right, the idea is that you call start_daemon() to
begin daemonizing.  Then you do a bunch of stuff in the child process
that needs to happen in the child process, but which might fail.  If
it fails, you can just exit.  If it succeeds, you inform the parent
process of your success, and then exit.  That way:

  * The parent process can learn about and report some common kinds of
initialization failure, and
  * The parent process doesn't exit until the child is well and truly launched.

It's been that way since cacacfe2b1  (originally svn:969).
Unfortunately, the only commit message we have from back from when we
added the commit (8.5 years ago!) is "Integrate new daemon code,
adapted from submission by christian grothoff".

yrs,
-- 
Nick


More information about the tor-dev mailing list