From 45aad3a7fb17edf1aa382bc0a7f561758089d121 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 23 Feb 2012 11:14:40 -0500 Subject: [PATCH] FreeBSD port: lttng_clone_files should execute handler Signed-off-by: Mathieu Desnoyers --- src/common/compat/clone.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/common/compat/clone.h b/src/common/compat/clone.h index 6685c6f6e..c3605080e 100644 --- a/src/common/compat/clone.h +++ b/src/common/compat/clone.h @@ -23,7 +23,7 @@ #include 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 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 -- 2.34.1