From: Roger Pau Monne <roger.pau@entel.upc.edu>
To: xen-devel@lists.xensource.com
Subject: [PATCH 4 of 9] libxl: add libxl__forkexec to execute hotplug scripts
Date: Fri, 14 Oct 2011 15:35:36 +0200 [thread overview]
Message-ID: <0235e192a519e29ac3d7.1318599336@loki> (raw)
In-Reply-To: <patchbomb.1318599332@loki>
# HG changeset patch
# User Roger Pau Monne <roger.pau@entel.upc.edu>
# Date 1318592310 -7200
# Node ID 0235e192a519e29ac3d77e91fe59b38e6a6f06ef
# Parent 0865f90beac01012dd0ff4a86b07d8fb62575163
libxl: add libxl__forkexec to execute hotplug scripts
Add a new function to libxl_exec that performs a vfork and executes the passed arguments using libxl__exec.
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
diff -r 0865f90beac0 -r 0235e192a519 tools/libxl/libxl_exec.c
--- a/tools/libxl/libxl_exec.c Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl_exec.c Fri Oct 14 13:38:30 2011 +0200
@@ -308,3 +308,25 @@ int libxl__spawn_check(libxl__gc *gc, vo
for_spawn->intermediate = 0;
return ERROR_FAIL;
}
+
+int libxl__forkexec(libxl__gc *gc, int stdinfd, int stdoutfd,
+ int stderrfd, char **args)
+{
+ libxl_ctx *ctx = libxl__gc_owner(gc);
+
+ switch (vfork()) {
+ case -1:
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to vfork\n");
+ return -1;
+ case 0:
+ libxl__exec(stdinfd, stdoutfd, stderrfd, args[0], args);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to execute %s\n",
+ args[0]);
+ exit(EXIT_FAILURE);
+ break;
+ default:
+ wait(NULL);
+ break;
+ }
+ return 0;
+}
diff -r 0865f90beac0 -r 0235e192a519 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl_internal.h Fri Oct 14 13:38:30 2011 +0200
@@ -342,6 +342,8 @@ _hidden int libxl__spawn_check(libxl__gc
_hidden void libxl__exec(int stdinfd, int stdoutfd, int stderrfd,
const char *arg0, char **args); // logs errors, never returns
+_hidden int libxl__forkexec(libxl__gc *gc, int stdinfd, int stdoutfd,
+ int stderrfd, char **args);
_hidden void libxl__log_child_exitstatus(libxl__gc *gc,
const char *what, pid_t pid, int status);
next prev parent reply other threads:[~2011-10-14 13:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-14 13:35 [PATCH 0 of 9] Call hotplug scripts from libxl for NetBSD Roger Pau Monne
2011-10-14 13:35 ` [PATCH 1 of 9] xenbackendd: pass type of block device to hotplug script Roger Pau Monne
2011-10-14 13:35 ` [PATCH 2 of 9] libxl: fix for libxl not waiting for devices to disconnect Roger Pau Monne
2011-10-14 13:35 ` [PATCH 3 of 9] libxl: add support for image files for NetBSD Roger Pau Monne
2011-10-14 13:35 ` Roger Pau Monne [this message]
2011-10-14 13:35 ` [PATCH 5 of 9] libxl: wait for devices to initialize upon addition to the domain Roger Pau Monne
2011-10-14 13:35 ` [PATCH 6 of 9] libxl: execute hotplug scripts directly from libxl Roger Pau Monne
2011-10-14 13:35 ` [PATCH 7 of 9] hotplug NetBSD: detach devices when state is 5 or 6 Roger Pau Monne
2011-10-14 13:35 ` [PATCH 8 of 9] hotplug: remove debug messages from NetBSD hotplug scripts Roger Pau Monne
2011-10-14 13:35 ` [PATCH 9 of 9] rc.d NetBSD: don't start xenbackendd by default, only when xend needs it Roger Pau Monne
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=0235e192a519e29ac3d7.1318599336@loki \
--to=roger.pau@entel.upc.edu \
--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 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.