aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_event.h
diff options
context:
space:
mode:
authorIan Jackson <ian.jackson@eu.citrix.com>2012-04-11 14:14:18 +0100
committerIan Jackson <ian.jackson@eu.citrix.com>2012-04-11 14:14:18 +0100
commitda31ffa712dbbe9540a7b9c2b7bee4d3315c1cd1 (patch)
treed9134fca3659e8a649f433d03f8aacc620101675 /tools/libxl/libxl_event.h
parent88d3e27049298a53d9f9f5c8600d2799dc88ef7b (diff)
downloadxen-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/libxl_event.h')
-rw-r--r--tools/libxl/libxl_event.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/libxl/libxl_event.h b/tools/libxl/libxl_event.h
index ea553f61e6..2d2196f34a 100644
--- a/tools/libxl/libxl_event.h
+++ b/tools/libxl/libxl_event.h
@@ -371,6 +371,19 @@ void libxl_osevent_occurred_fd(libxl_ctx *ctx, void *for_libxl,
*/
void libxl_osevent_occurred_timeout(libxl_ctx *ctx, void *for_libxl);
+
+/*
+ * An application which initialises a libxl_ctx in a parent process
+ * and then forks a child which does not quickly exec, must
+ * instead libxl_postfork_child_noexec in the child. One call
+ * on any existing (or specially made) ctx is sufficient; after
+ * this all previously existing libxl_ctx's are invalidated and
+ * must not be used - or even freed. It is harmless to call this
+ * postfork function and then exec anyway.
+ */
+void libxl_postfork_child_noexec(libxl_ctx *ctx);
+
+
#endif
/*