From: Mathieu Desnoyers Date: Thu, 23 Feb 2012 16:14:40 +0000 (-0500) Subject: FreeBSD port: lttng_clone_files should execute handler X-Git-Tag: v2.0.0-rc3~28 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=45aad3a7fb17edf1aa382bc0a7f561758089d121;p=lttng-tools.git FreeBSD port: lttng_clone_files should execute handler Signed-off-by: Mathieu Desnoyers --- 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