From: Ian Jackson Subject: Re: [PATCH v2] xl: track child processes for the benefit of libxl Date: Tue, 22 May 2012 12:17:11 +0100 Message-ID: <20411.30135.659467.276549@mariner.uk.xensource.com> References: <20406.37918.733921.594303@mariner.uk.xensource.com> <1337675069.10118.11.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1337675069.10118.11.camel@zakaz.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 Campbell Cc: Roger Pau Monne , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("Re: [PATCH v2] xl: track child processes for the benefit of libxl"): > On Fri, 2012-05-18 at 19:25 +0100, Ian Jackson wrote: > > +pid_t xl_waitpid(xlchildnum child, int *status, int flags) > > +{ > > + xlchild *ch = &children[child]; > > + pid_t got = ch->pid; > > + assert(got); > > + if (ch->reaped) { > > + *status = ch->status; > > + ch->pid = 0; > > + return got; > > + } > > + for (;;) { > > + got = waitpid(ch->pid, status, flags); > > Is it always the case that xl has at most one child? I don't think it is necessarily the case. > Because if not then we may reap the wrong one here. No, the whole point of waitpid is that you get to specify which child to reap. Unless I'm missing something ? ch->pid the same as children[child].pid which is the pid of the child we want to wait for, and the previous code has just checked whether we have reaped it already so we are guaranteed not to reap a new different child with the same pid and get confused (should such a thing happen to happen). > > +typedef struct { > > + /* every struct like this must be in XLCHILD_LIST */ > > This comment is obsolete now. Oh yes. Ian.