WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Re: [Xen-changelog] Detach Xend from terminal, courtesy

To: Anthony Liguori <aliguori@xxxxxxxxxx>
Subject: Re: [Xen-devel] Re: [Xen-changelog] Detach Xend from terminal, courtesy of Horms <horms@xxxxxxxxxxxx>.
From: Ewan Mellor <ewan@xxxxxxxxxxxxx>
Date: Fri, 9 Dec 2005 21:16:22 +0000
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Fri, 09 Dec 2005 21:17:24 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4399ED6F.1050500@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <E1EkjTm-0004PC-NQ@xxxxxxxxxxxxxxxxxxxxx> <4399ED6F.1050500@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.9i
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