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

Re: [Xen-devel] [PATCH] tools/libxl: Initialise both parts of ctx->sigchld_selfpipe[] to -1



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 <stdio.h>
#include <stdlib.h>
#include <libxl.h>

#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

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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