diff options
author | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-04-11 14:14:18 +0100 |
---|---|---|
committer | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-04-11 14:14:18 +0100 |
commit | da31ffa712dbbe9540a7b9c2b7bee4d3315c1cd1 (patch) | |
tree | d9134fca3659e8a649f433d03f8aacc620101675 /tools/libxl/xl.c | |
parent | 88d3e27049298a53d9f9f5c8600d2799dc88ef7b (diff) | |
download | xen-da31ffa712dbbe9540a7b9c2b7bee4d3315c1cd1.tar.gz xen-da31ffa712dbbe9540a7b9c2b7bee4d3315c1cd1.tar.bz2 xen-da31ffa712dbbe9540a7b9c2b7bee4d3315c1cd1.zip |
libxl: Protect fds with CLOEXEC even with forking threads
We introduce a new "carefd" concept, which relates to fds that we care
about not being inherited by long-lived children.
As yet we do not use this anywhere in libxl. Until all locations in
libxl which make such fds are converted, libxl__postfork may not work
entirely properly. If these locations do not use O_CLOEXEC (or use
calls for which there is no O_CLOEXEC) then multithreaded programs may
not work properly.
This introduces a new API call libxl_postfork_child_noexec which must
be called by applications which make long-running non-execing
children. Add the appropriate call to xl's postfork function.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/xl.c')
-rw-r--r-- | tools/libxl/xl.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c index 62c0abde96..a6ffd25ff7 100644 --- a/tools/libxl/xl.c +++ b/tools/libxl/xl.c @@ -96,6 +96,9 @@ static void parse_global_config(const char *configfile, void postfork(void) { + libxl_postfork_child_noexec(ctx); /* in case we don't exit/exec */ + ctx = 0; + if (libxl_ctx_alloc(&ctx, LIBXL_VERSION, 0, (xentoollog_logger*)logger)) { fprintf(stderr, "cannot reinit xl context after fork\n"); exit(-1); |