From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Bligh Subject: Re: [PATCH] tools/libxl: Initialise both parts of ctx->sigchld_selfpipe[] to -1 Date: Mon, 18 Aug 2014 15:18:34 +0100 Message-ID: <53F20B3A.8040408@alex.org.uk> References: <1408366957-19860-1-git-send-email-andrew.cooper3@citrix.com> <53F1FB2D.3010407@alex.org.uk> <53F1FD73.9050503@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <53F1FD73.9050503@citrix.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: Andrew Cooper Cc: Xen Devel List-Id: xen-devel@lists.xenproject.org On 18/08/2014 14:19, Andrew Cooper wrote: > It looks like a call to libxl_childproc_setmode() will properly set up > both halves of ctx->sigchld_selfpipe[] > > The call is to do with setting up the ownership of SIGCHILD in the > process, and a call to libxl_childproc_setmode(ctx, NULL, 0) should be > fine if you dont plan to fork in your own code. That does not appear to make any difference. As far as I can see I need to ensure libxl__sigchld_needed gets called, which means I need to ensure perhaps_sigchld_needed gets called and chldmode_ours returns true. As 'creating' is false, in libxl_sigchld_owner_libxl mode, I appear to need a child for this to work. I can set it to libxl_sigchld_owner_libxl_always or libxl_sigchld_owner_libxl_always_selective_reap and then set it back. The code below is the minimum I can find that gets it to work: #include #include #include #define LIBXL_API_VERSION 0x040200 /* compile with: * gcc -g -O0 xentest.c -o xentest -lxenlight */ void fixctx (libxl_ctx *ctx) { const libxl_childproc_hooks libxl_child_hooks = { .chldowner = libxl_sigchld_owner_libxl_always }; libxl_childproc_setmode (ctx, &libxl_child_hooks, 0); libxl_childproc_setmode (ctx, NULL, 0); } void test () { libxl_ctx *ctx = NULL; if (libxl_ctx_alloc (&ctx, LIBXL_VERSION, XTL_NONE, NULL)) { fprintf (stderr, "libxl_ctx_alloc failed"); exit (1); } fixctx (ctx); libxl_ctx_free (ctx); } int main (int argc, char **argv) { printf ("Before:\n"); system ("ls -la /proc/self/fd"); test (); printf ("\nAfter:\n"); system ("ls -la /proc/self/fd"); exit (0); } -- Alex Bligh