[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-dev] start_daemon and finish_daemon



On Wed, Jun 13, 2012 at 7:26 PM, Zack Weinberg <zackw@xxxxxxxxx> 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
_______________________________________________
tor-dev mailing list
tor-dev@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev