xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jim Fehlig <jfehlig@suse.com>
To: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: xen-devel@lists.xensource.com, Ian Campbell <ian.campbell@citrix.com>
Subject: Re: [PATCH 07/12] libxl: fork: Provide ..._always_selective_reap
Date: Fri, 17 Jan 2014 15:17:01 -0700	[thread overview]
Message-ID: <52D9ABDD.5020804@suse.com> (raw)
In-Reply-To: <1389975845-1195-8-git-send-email-ian.jackson@eu.citrix.com>

Ian Jackson wrote:
> Applications exist which want to use libxl in an event-driven mode but
> which do not integrate child termination into their event system, but
> instead reap all their own children synchronously.
>
> In such an application libxl must own SIGCHLD but avoid reaping any
> children that don't belong to libxl.
>
> Provide libxl_sigchld_owner_libxl_always_selective_reap which has this
> behaviour.
>
> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
> Cc: Jim Fehlig <jfehlig@suse.com>
> Cc: Ian Campbell <Ian.Campbell@citrix.com>
> Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
>
> ---
> v2: Document the new mode in the big "Subprocess handling" comment.
> ---
>  tools/libxl/libxl_event.h |   11 +++++++++++
>  tools/libxl/libxl_fork.c  |    7 +++++++
>  2 files changed, 18 insertions(+)
>
> diff --git a/tools/libxl/libxl_event.h b/tools/libxl/libxl_event.h
> index 3c93955..824ac88 100644
> --- a/tools/libxl/libxl_event.h
> +++ b/tools/libxl/libxl_event.h
> @@ -474,6 +474,12 @@ void libxl_osevent_occurred_timeout(libxl_ctx *ctx, void *for_libxl)
>   *       and provides a callback to be notified of their exit
>   *       statues.  The application must have only one libxl_ctx
>   *       configured this way.
> + *
> + *     libxl_sigchld_owner_libxl_always_selective_reap:
> + *
> + *       The application expects to reap all of its own children
> + *       synchronously, and does not use SIGCHLD.  libxl is
> + *       to install a SIGCHLD handler.
>   */
>  
>  
> @@ -491,6 +497,11 @@ typedef enum {
>      /* libxl owns SIGCHLD all the time, and the application is
>       * relying on libxl's event loop for reaping its children too. */
>      libxl_sigchld_owner_libxl_always,
> +
> +    /* libxl owns SIGCHLD all the time, but it must only reap its own
> +     * children.  The application will reap its own children
> +     * synchronously with waitpid, without the assistance of SIGCHLD. */
> +    libxl_sigchld_owner_libxl_always_selective_reap,
>   

ACK to the doc improvements here.  Much clearer IMO.

Regards,
Jim

>  } libxl_sigchld_owner;
>  
>  typedef struct {
> diff --git a/tools/libxl/libxl_fork.c b/tools/libxl/libxl_fork.c
> index b2325e0..16e17f6 100644
> --- a/tools/libxl/libxl_fork.c
> +++ b/tools/libxl/libxl_fork.c
> @@ -268,6 +268,7 @@ static bool chldmode_ours(libxl_ctx *ctx, bool creating)
>      case libxl_sigchld_owner_mainloop:
>          return 0;
>      case libxl_sigchld_owner_libxl_always:
> +    case libxl_sigchld_owner_libxl_always_selective_reap:
>          return 1;
>      }
>      abort();
> @@ -398,6 +399,12 @@ static void sigchld_selfpipe_handler(libxl__egc *egc, libxl__ev_fd *ev,
>      int e = libxl__self_pipe_eatall(selfpipe);
>      if (e) LIBXL__EVENT_DISASTER(egc, "read sigchld pipe", e, 0);
>  
> +    if (CTX->childproc_hooks->chldowner
> +        == libxl_sigchld_owner_libxl_always_selective_reap) {
> +        childproc_checkall(egc);
> +        return;
> +    }
> +
>      while (chldmode_ours(CTX, 0) /* in case the app changes the mode */) {
>          int status;
>          pid_t pid = checked_waitpid(egc, -1, &status);
>   

  reply	other threads:[~2014-01-17 22:17 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-17 16:23 [PATCH 00/12] libxl: fork: SIGCHLD flexibility Ian Jackson
2014-01-17 16:23 ` [PATCH 01/12] libxl: fork: Break out checked_waitpid Ian Jackson
2014-01-17 16:23 ` [PATCH 02/12] libxl: fork: Break out childproc_reaped_ours Ian Jackson
2014-01-17 16:23 ` [PATCH 03/12] libxl: fork: Clarify docs for libxl_sigchld_owner Ian Jackson
2014-01-17 16:23 ` [PATCH 04/12] libxl: fork: Document libxl_sigchld_owner_libxl better Ian Jackson
2014-01-17 16:28   ` Ian Campbell
2014-01-17 16:23 ` [PATCH 05/12] libxl: fork: assert that chldmode is right Ian Jackson
2014-01-17 16:23 ` [PATCH 06/12] libxl: fork: Provide libxl_childproc_sigchld_occurred Ian Jackson
2014-01-17 16:24 ` [PATCH 07/12] libxl: fork: Provide ..._always_selective_reap Ian Jackson
2014-01-17 22:17   ` Jim Fehlig [this message]
2014-01-17 16:24 ` [PATCH 08/12] libxl: fork: Provide LIBXL_HAVE_SIGCHLD_SELECTIVE_REAP Ian Jackson
2014-01-17 16:24 ` [PATCH 09/12] libxl: fork: Rename sigchld handler functions Ian Jackson
2014-01-20  9:59   ` Ian Campbell
2014-01-17 16:24 ` [PATCH 10/12] libxl: fork: Break out sigchld_installhandler_core Ian Jackson
2014-01-20  9:59   ` Ian Campbell
2014-01-17 16:24 ` [PATCH 11/12] libxl: fork: Break out sigchld_sethandler_raw Ian Jackson
2014-01-20  9:58   ` Ian Campbell
2014-01-20 17:57     ` Ian Jackson
2014-01-17 16:24 ` [PATCH 12/12] libxl: fork: Share SIGCHLD handler amongst ctxs Ian Jackson
2014-01-17 18:13   ` Ian Jackson
2014-01-20  9:56     ` Ian Campbell
2014-01-21 14:40       ` Ian Jackson
2014-01-21 14:53         ` Ian Campbell
2014-01-21 15:09           ` Ian Jackson
2014-01-17 16:37 ` [PATCH 00/12] libxl: fork: SIGCHLD flexibility Ian Jackson
2014-01-17 22:29 ` Jim Fehlig
2014-01-20 18:14   ` Jim Fehlig
2014-01-21 14:46     ` Ian Jackson
2014-01-21 15:11       ` [PATCH 13/12] libxl: events: Break out libxl__pipe_nonblock, _close Ian Jackson
2014-01-21 15:11         ` [PATCH 14/12] libxl: fork: Make SIGCHLD self-pipe nonblocking Ian Jackson
2014-01-21 15:32           ` Ian Campbell
2014-01-21 15:48             ` Ian Jackson
2014-01-21 15:27         ` [PATCH 13/12] libxl: events: Break out libxl__pipe_nonblock, _close Ian Campbell
2014-01-21 15:31           ` Ian Jackson
2014-01-21 15:28     ` [PATCH 00/12] libxl: fork: SIGCHLD flexibility Ian Jackson
2014-01-22  5:32       ` Jim Fehlig
2014-01-23  4:05         ` Jim Fehlig
2014-01-23 10:56           ` Ian Jackson
2014-01-23 21:36             ` Jim Fehlig
2014-01-24  4:27             ` Jim Fehlig
2014-01-24 12:41               ` Ian Jackson
2014-01-24 12:52                 ` Ian Campbell
2014-01-24 15:14                   ` Ian Jackson
2014-01-24 15:18                     ` Ian Jackson
2014-01-24 16:36                     ` Ian Jackson
2014-01-24 16:57                       ` Ian Jackson
2014-01-27  5:39                   ` Jim Fehlig
2014-01-27  5:22                 ` Jim Fehlig
2014-01-27 14:48                   ` Ian Jackson
2014-01-28  1:39                 ` [libvirt] [Xen-devel] " Jim Fehlig
2014-01-28 10:06                   ` Daniel P. Berrange
2014-01-29 16:23                     ` [libvirt] " Ian Jackson
2014-01-30 12:18                   ` [libvirt] [Xen-devel] " Daniel P. Berrange
2014-01-30 16:14                     ` Jim Fehlig
2014-01-30 16:17                       ` Daniel P. Berrange
2014-01-30 16:28                   ` Ian Jackson
2014-01-30 16:56                     ` Jim Fehlig
2014-01-30 17:12                       ` [libvirt] [Xen-devel] " Ian Jackson

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=52D9ABDD.5020804@suse.com \
    --to=jfehlig@suse.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).