From 2fe033acfc82d768fd7b91016bc6205e1c44d7a3 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 11 May 2012 18:59:06 +0100 Subject: libxl: child processes cleanups Abolish libxl_fork. Its only callers were in xl. Its functionality is now moved elsewhere, as follows: * The "logging version of fork", which is what it was billed as, is now xl_fork, which also dies on failure. * Closing the xenstore handle in the child is now done in libxl__ev_child_fork, which is the only remaining place where fork is called in libxl. * We provide a new function libxl__ev_child_xenstore_reopen for in-libxl children to make the ctx useable for xenstore again. * Consequently libxl__spawn_record_pid now no longer needs to mess about with its own xenstore handle. As a bonus it can now just use libxl__xs_write. Also, since we have now converted all the forkers in libxl, we can always honour the fork_replacement childproc hook - so do so. Signed-off-by: Ian Jackson Acked-by: Ian Campbell Committed-by: Ian Jackson --- tools/libxl/libxl_utils.c | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'tools/libxl/libxl_utils.c') diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index f0d94c6828..858410e7bc 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -444,27 +444,6 @@ int libxl__remove_directory(libxl__gc *gc, const char *dirpath) return rc; } -pid_t libxl_fork(libxl_ctx *ctx) -{ - pid_t pid; - - pid = fork(); - if (pid == -1) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "fork failed"); - return -1; - } - - if (!pid) { - if (ctx->xsh) xs_daemon_destroy_postfork(ctx->xsh); - ctx->xsh = 0; - /* This ensures that anyone who forks but doesn't exec, - * and doesn't reinitialise the libxl_ctx, is OK. - * It also means they can safely call libxl_ctx_free. */ - } - - return pid; -} - int libxl_pipe(libxl_ctx *ctx, int pipes[2]) { if (pipe(pipes) < 0) { -- cgit v1.2.3