[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 6/7] libxl: fork: Provide ..._always_selective_reap
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@xxxxxxxxxxxxx> Cc: Jim Fehlig <jfehlig@xxxxxxxx> Cc: Ian Campbell <Ian.Campbell@xxxxxxxxxx> --- tools/libxl/libxl_event.h | 5 +++++ tools/libxl/libxl_fork.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/tools/libxl/libxl_event.h b/tools/libxl/libxl_event.h index 12e3d1f..c09e3ed 100644 --- a/tools/libxl/libxl_event.h +++ b/tools/libxl/libxl_event.h @@ -480,6 +480,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, } 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); -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |