From 7cf2b4146811fc238452e65d1cd573ea5f473970 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Mon, 6 Jul 2020 11:05:14 +0200 Subject: [PATCH] bindings: provide lxcfs_clone() as wrapper around lxcfs_raw_clone() Closes: #420. Signed-off-by: Christian Brauner --- src/bindings.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/bindings.h b/src/bindings.h index 4ab4f721..e2609029 100644 --- a/src/bindings.h +++ b/src/bindings.h @@ -104,6 +104,20 @@ static inline int install_signal_handler(int signo, return sigaction(signo, &action, NULL); } -extern pid_t lxcfs_clone(int (*fn)(void *), void *arg, int flags); +extern pid_t lxcfs_raw_clone(unsigned long flags, int *pidfd); + +static inline pid_t lxcfs_clone(int (*fn)(void *), void *arg, int flags) +{ + pid_t pid; + + pid = lxcfs_raw_clone(flags, NULL); + if (pid < 0) + return -1; + + if (pid == 0) + _exit(fn(arg)); + + return pid; +} #endif /* __LXCFS_BINDINGS_H */