All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Bligh <alex@alex.org.uk>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Xen Devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH] tools/libxl: Initialise both parts of ctx->sigchld_selfpipe[] to -1
Date: Mon, 18 Aug 2014 15:18:34 +0100	[thread overview]
Message-ID: <53F20B3A.8040408@alex.org.uk> (raw)
In-Reply-To: <53F1FD73.9050503@citrix.com>

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

  reply	other threads:[~2014-08-18 14:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-18 13:02 [PATCH] tools/libxl: Initialise both parts of ctx->sigchld_selfpipe[] to -1 Andrew Cooper
2014-08-18 13:10 ` Alex Bligh
2014-08-18 13:19   ` Andrew Cooper
2014-08-18 14:18     ` Alex Bligh [this message]
2014-08-26 23:34 ` Andrew Cooper
2014-08-27  1:55 ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53F20B3A.8040408@alex.org.uk \
    --to=alex@alex.org.uk \
    --cc=andrew.cooper3@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.