FreeBSD port: lttng_clone_files should execute handler
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 23 Feb 2012 16:14:40 +0000 (11:14 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 23 Feb 2012 16:14:40 +0000 (11:14 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/common/compat/clone.h

index 6685c6f6e9ed084ac5817beb5abe4c4f635a0e9f..c3605080e8eac4ad38ec96557bbae96b77da4277 100644 (file)
@@ -23,7 +23,7 @@
 #include <sched.h>
 
 static inline
-int lttng_clone_files(int (*fn)(void *), void *child_stack, void *arg)
+pid_t lttng_clone_files(int (*fn)(void *), void *child_stack, void *arg)
 {
        return clone(fn, child_stack, CLONE_FILES | SIGCHLD, arg);
 }
@@ -33,9 +33,27 @@ int lttng_clone_files(int (*fn)(void *), void *child_stack, void *arg)
 #include <unistd.h>
 
 static inline
-int lttng_clone_files(int (*fn)(void *), void *child_stack, void *arg)
+pid_t lttng_clone_files(int (*fn)(void *), void *child_stack, void *arg)
 {
-       return rfork(RFPROC | RFTHREAD);
+       pid_t pid;
+
+       pid = rfork(RFPROC | RFTHREAD);
+       if (pid == 0) {
+               /* child */
+               int ret;
+
+               ret = fn(arg);
+               exit(ret);
+       } else if (pid > 0) {
+               /* parent */
+               /*
+                * Just return, the caller will wait for the child.
+                */
+               return pid;
+       } else {
+               /* Error */
+               return pid;
+       }
 }
 
 #else
This page took 0.034002 seconds and 4 git commands to generate.