From: Ian Campbell Subject: Re: [PATCH] xl: track child processes for the benefit of libxl Date: Fri, 18 May 2012 13:25:45 +0100 Message-ID: <1337343945.22316.91.camel@zakaz.uk.xensource.com> References: <20404.4261.794115.716972@mariner.uk.xensource.com> <1337250836.7781.46.camel@zakaz.uk.xensource.com> <20406.10969.280469.436947@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20406.10969.280469.436947@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: Roger Pau Monne , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Fri, 2012-05-18 at 11:56 +0100, Ian Jackson wrote: [...] > typedef enum { > child_console, child_waitdaemon, child_migration, > child_max > } xlchildnum; > extern xlchild children[child_max]; > > pid_t xl_waitpid(enum xlchildnum, ....); > > xl_waitpid(child_console, ....); [...] > Pick one; they all seem plausible to me. Likewise. Not that keen on the union one but the others are all broadly similar. > My favourite is probably the one where we pass the array index to > xl_fork and xl_waitpid. You mean the one I haven't trimmed above? I think I'd be happy with that. > > > - *pid = fork(); > > > - if (*pid < 0) { > > > + console_child_report(); > > > + > > > + pid_t pid = xl_fork(&child_console); > > > > console_child_report doesn't seem to reset child_config.pid and xlfork > > has an assert(!foo.pid) in it, so how does this work on the second time? > > xl_waitpid does it. Perhaps this is worth a comment ? Yes, since you rely on BSS zeroing and waitpid (i.e. teardown) to (re)initialise the state I think a comment would be handy. Ian.