Implement CLONE_FILES compat layer with rfork
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 23 Feb 2012 00:26:47 +0000 (19:26 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 23 Feb 2012 00:26:47 +0000 (19:26 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/common/compat/clone.h
src/common/runas.c

index 45eb37982c225c9551fe10b3f3f8ba909092a8e4..08aa10dcd199a0431845bc0a279fc9b4b30896f8 100644 (file)
 
 #include <sched.h>
 
+static inline
+int lttng_clone_files(int (*fn)(void *), void *child_stack, void *arg)
+{
+       return clone(fn, child_stack, CLONE_FILES | SIGCHLD, arg);
+}
+
 #elif __FreeBSD__
 
 #include <unistd.h>
 
-#define CLONE_FILES 0
-
-#define clone(fct_ptr, child_stack, flags, arg, args...) \
-       compat_clone(fct_ptr, child_stack, flags, arg)
-
-int compat_clone(int (*fn)(void *), void *child_stack, int flags,
-               void *arg)
+static inline
+int lttng_clone_files(int (*fn)(void *), void *child_stack, void *arg)
 {
-       return -ENOSYS;
+       return rfork(RFPROC | RFTHREAD);
 }
 
 #else
index bee107951d8664e6f111ed5ff260574407f0c3a3..86db9b8682c343efaee59a08bee72123fc518d60 100644 (file)
@@ -237,9 +237,8 @@ int run_as(int (*cmd)(void *data), void *data, uid_t uid, gid_t gid)
         * Pointing to the middle of the stack to support architectures
         * where the stack grows up (HPPA).
         */
-       pid = clone(child_run_as, child_stack + (RUNAS_CHILD_STACK_SIZE / 2),
-               CLONE_FILES | SIGCHLD,
-               &run_as_data, NULL);
+       pid = lttng_clone_files(child_run_as, child_stack + (RUNAS_CHILD_STACK_SIZE / 2),
+               &run_as_data);
        if (pid < 0) {
                perror("clone");
                ret = pid;
This page took 0.027179 seconds and 4 git commands to generate.