[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] Re: [Xen-changelog] Detach Xend from terminal, courtesy of Horms <horms@xxxxxxxxxxxx>.



On Fri, Dec 09, 2005 at 02:47:43PM -0600, Anthony Liguori wrote:

> Sorry I missed this on Xen devel, but could someone explain this patch a 
> little more.  The old behavior purposefully delayed the terminal 
> detaching until Xend was ready to accept connections.  This is necessary 
> to avoid a race condition with executing the first xm command after a 
> xend start.
> 
> I don't quite understand why two fork()s would be required to properly 
> daemonize.  I don't know of any other daemons that do that (certainly, 
> xenstored and xenconsoled don't).

It's a standard technique on Unixen.  You need to fork before calling setsid
to ensure that you are not a process group leader, then afterwards to ensure
that children cannot regain the terminal.  See

http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16

(If xenstored and xenconsoled aren't doing this, then they ought to.)

We have preserved the behaviour whereby the Xend process does not exit until it
is ready to accept connections -- it's just one fork further on (and there's
a patch with another fork on its way, for your amusement, but that's a different
story ;-)

Ewan. 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.