aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_exec.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-01-12 07:06:12 +0000
committerKeir Fraser <keir.fraser@citrix.com>2010-01-12 07:06:12 +0000
commit4d5c98f988e637f05b60a5fa9d673d5836f894f9 (patch)
tree4480858fd3db4b30bd19f0f5c1bfbd0e37adc163 /tools/libxl/libxl_exec.c
parent246098effc519b8b44858207d2c587d9e24a5f98 (diff)
downloadxen-4d5c98f988e637f05b60a5fa9d673d5836f894f9.tar.gz
xen-4d5c98f988e637f05b60a5fa9d673d5836f894f9.tar.bz2
xen-4d5c98f988e637f05b60a5fa9d673d5836f894f9.zip
libxenlight: remove ctx dangerously passed to children
apart from ctx->waitpid, it's potentially harmful to call into logging. Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxl_exec.c')
-rw-r--r--tools/libxl/libxl_exec.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/libxl/libxl_exec.c b/tools/libxl/libxl_exec.c
index 011ed8452d..e8cc74c7da 100644
--- a/tools/libxl/libxl_exec.c
+++ b/tools/libxl/libxl_exec.c
@@ -100,8 +100,7 @@ void libxl_report_child_exitstatus(struct libxl_ctx *ctx,
int libxl_spawn_spawn(struct libxl_ctx *ctx,
libxl_device_model_starting *starting,
const char *what,
- void (*intermediate_hook)(struct libxl_ctx *ctx,
- void *for_spawn,
+ void (*intermediate_hook)(void *for_spawn,
pid_t innerchild))
{
pid_t child, got;
@@ -127,18 +126,19 @@ int libxl_spawn_spawn(struct libxl_ctx *ctx,
/* we are now the intermediate process */
- child = libxl_fork(ctx);
- if (!child) return 0; /* caller runs child code */
- if (child < 0) exit(255);
+ child = fork();
+ if (child == -1)
+ exit(255);
+ if (!child)
+ return 0; /* caller runs child code */
- intermediate_hook(ctx, starting, child);
+ intermediate_hook(starting, child);
if (!for_spawn) _exit(0); /* just detach then */
got = call_waitpid(ctx->waitpid_instead, child, &status, 0);
assert(got == child);
- libxl_report_child_exitstatus(ctx, what, child, status);
_exit(WIFEXITED(status) ? WEXITSTATUS(status) :
WIFSIGNALED(status) && WTERMSIG(status) < 127
? WTERMSIG(status)+128 : -1);